sry i thinki misspelled d ques
d ques was
how will you protect a derived class to override base class's member
function in c++
say if there is a function f() in base class then derived should not be able
to
override f() to provide its own definition.
but The function must be
By declaring the function a static final f().
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*
On Sun, Jul 31, 2011 at 7:28 AM, himanshu kansal
himanshukansal...@gmail.com wrote:
sry i thinki misspelled d ques
d ques was
how will you protect a derived class to override
i think there is no keyword known as final in c++.maybe u are talking
with respect to java
On Sun, Jul 31, 2011 at 8:03 PM, muthu raj muthura...@gmail.com wrote:
By declaring the function a static final f().
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*
On Sun, Jul 31,
Yeah but there is no equivalent of final keyword in c++.So to prevent
member function from overriding in derived class in c++ dont declare the
member function as virtual. Then it cannot be overridden in derived class.
There is no other way of preventing a member function of base class from
what if we write that function as private of base class.. and make a
function in derived class that is friend function of the base class do that
it can call tht private function of base.??
On Sun, Jul 31, 2011 at 8:25 PM, muthu raj muthura...@gmail.com wrote:
Yeah but there is no equivalent of
Using friend functions we can only invoke already defined private functions.
We cannot override or prevent overriding using friend functions. The problem
here is how to prevent base class function from being overridden in derived
class.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*
On Sun,
@ muthu : not declaring tht function as virtual wont save overriding
class A
{
int a;
public:
void f()
{}
int f2(){}
};
class B:public A
{
public:
void f()
{
coutabc\n;
}
};
int main()
{
B ob;
ob.f();
return 0;
}
in this output is abc..
so
@anika: This is not function overriding i think .. you cannot call the f()
function of the base class from the derived class object .. what you are
doing is creating a object of the derived class and calling the version of
f() that belong to derived class B .. ie is the same class object is
ohkk.. m so sorry
On Sun, Jul 31, 2011 at 9:41 PM, Ankit Minglani ankit.mingl...@gmail.comwrote:
@anika: This is not function overriding i think .. you cannot call the f()
function of the base class from the derived class object .. what you are
doing is creating a object of the derived class
@ Ankit: Wat is overriding actually thn?
On Sun, Jul 31, 2011 at 9:58 PM, Anika Jain anika.jai...@gmail.com wrote:
ohkk.. m so sorry
On Sun, Jul 31, 2011 at 9:41 PM, Ankit Minglani
ankit.mingl...@gmail.comwrote:
@anika: This is not function overriding i think .. you cannot call the f()
overriding redefining virtual function..
Well then as per this definition not defining the func as virtual is nt the
solution..
On Sun, Jul 31, 2011 at 10:04 PM, aditi garg aditi.garg.6...@gmail.comwrote:
@ Ankit: Wat is overriding actually thn?
On Sun, Jul 31, 2011 at 9:58 PM, Anika Jain
sorry overriding is redifining virtual function
On Sun, Jul 31, 2011 at 10:05 PM, Anika Jain anika.jai...@gmail.com wrote:
overriding redefining virtual function..
Well then as per this definition not defining the func as virtual is nt the
solution..
On Sun, Jul 31, 2011 at 10:04 PM, aditi
@aditi : in C++ you define a function virtual to let the derived class give
its own definition for the same. and in that case the functions are
overridden. unlike in JAVA where no virtual keyword is needed .. so if you
write the same code as above in java .. that may be referred to as Method
Overridden functions and virtual functions are two different concepts...
1) Two functions in the same scope having same but different signatures =
Over Loading
2) Two functions having same signatures but one defined in parent class and
the other defined in child class == Overriding
3) Virtual
sandeep ur misguiding all things are,.
for overriding virtual keyword is used that means virtual functions only
overriden.
In c++ u require to add virtual keyword.
and in java every non static function is by default virtual.
On Sun, Jul 31, 2011 at 10:23 PM, Sandeep Jain
@Pandharinath: Please consider the following e.g.
class A
{
public:
void func(){ /* A'simplementation */}
};
class B:public A
{
public:
void func(){/* B's implementation*/ }
};
What is B's func() doing?
Regards,
Sandeep Jain
On Sun, Jul 31, 2011 at 10:36 PM, pandharinath gorde
Function overriding gains significance only when functions are declared
virtual. Otherwise Overriding does not serve any purpose. the main idea
behind virtual functions and method overloading is to implement Dynamic
Polymorphism i.e decide which version of function(base or derived) to be
invoked
yes Sandeep(sir) is perfectly right , if we definig a base class function
in derived with exactly same function signature , the function in derived
class said to override the function in base class, does nt matter whether
it is virtual or not.
On Sun, Jul 31, 2011 at 10:22 AM, Sandeep Jain
Yup.. actually we never get to make proper usage of overridden functions
without making them virtual.
Regards,
Sandeep Jain
On Sun, Jul 31, 2011 at 10:55 PM, muthu raj muthura...@gmail.com wrote:
Function overriding gains significance only when functions are declared
virtual. Otherwise
@ muthuraj
see here display in derived is overriding display() in base and also has
purpose
class A
{
int a;
public :
void dispaly()
{
couta;
}
};
class B:public A
{
int b;
public :
void display()
{
A::dispaly();
coutb;
}
};
On Sun, Jul 31, 2011 at 10:25 AM, muthu raj
ok...i agree with the explanation given by sandeep regarding
overloading,overriding and virtual fns.
but i am not able to think if there exist any method to do the required task
!!
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Sun, Jul 31, 2011 at
@sandeep
class A
{
public:
void func(){ /* A'simplementation */}
};
class B:public A
{
public:
void func(){/* B's implementation*/ }
};
whatever is happening in this one is not overriding and not overloading
For overloading function should be is same scope but see below both func are
in
@sandeep
@sandeep
class A
{
public:
void func(){ /* A'simplementation */}
};
class B:public A
{
public:
void func(){/* B's implementation*/ }
};
whatever is happening in this one is not overriding and not overloading
For overloading function should be is same scope but see below both func are
So, what you are saying is
Overriding == virtual functions
As per this logic:
Simply remove the virtual keyword from the function definition in base
class, which would mean they will not be overridden by the derived class.
And this answers the original question asked in this thread.
Regards,
@bharath: To store the bunch of records together also, we gonna need
another useful ds like linked list or array which again points to
the problem of excessive storage or excessive pointers...
correct me if am not..!
On 7/28/11, bharath bharath.sri...@gmail.com wrote:
@Dumanshu: A B+ tree is a
@Puneet, to store anything on a machine, you will need to have a
pointer to it else there is no question of accessing it. I am guessing
the question emphasized on reducing the size of the B+ tree. Also,
with B+ trees, you have sequence pointers at the data record level.
Therefore, if these data
@bharath: yeah i was also thinking that we could store a pointer to a data
block in which multiple records can be stored.but i think for searching
a record we have to 1st get to that block and then search the record in that
block
On Thu, Jul 28, 2011 at 5:31 PM, bharath
A B+ tree would have one pointer for every data record at the leaf
level. You could additionally group a bunch of data records together
and have a single pointer from leaf to the data block. The trade-off
is that you will have to fetch the data block and sequentially parse
it to search for an
Use multilevel indexing
On Jul 27, 11:07 pm, himanshu kansal himanshukansal...@gmail.com
wrote:
if u hv say 20 million records and u have to create a b+ tree then you
might be storing 20 million pointers at the leaf levelhow can u
optimize this(using b+ tree only)???
--
You received
@Dumanshu: A B+ tree is a multi-level index. It indexes the index
until the final level is small enough to fit into a data block that
can fit in memory.
On Jul 27, 10:11 pm, Dumanshu duman...@gmail.com wrote:
Use multilevel indexing
On Jul 27, 11:07 pm, himanshu kansal
30 matches
Mail list logo