When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
constructors can not be inherited!
bcoz their work is to initialise the object of the class to
which they belong to!
so if they get inherited,how can they initialise the object
of the derived class!
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
The question is very absurd. From where did we get the
variable stuff? And ya, how on earth do we get private
members/functions being inherited? Kamlesh is right in
saying that The whole idea stinks.
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
before invoking derived class constructor base-class
constructor should be called.
1. first base-class object will be created then derived-
class object will be created.
2. here the base class constructor is private, so derived-
class cannot invoke it.
No object is created in derived-class.
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
Private Constructor is not inherited.
When private member varible is not inherited but the size is
occupid in dervied class object.
e.g.
#include <iostream.h>
class A
{
int x;
int y;
};
class B : private A
{
};
int main()
{
cout << sizeof(B);
}
output :
8
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
Neha, your question is not proper, please edit that. Some
where inheritance of private constructor and some where
private variable.
Please edit it so that people can help you.
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
When a constructor is made private, object of that class
can not be created. That is called as Abstract class.
constructors can not be inherited. Moreover, when this
class is inherited, the base class object can not be
created. So we can not create the derived class object
also.
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
When a constructor is made private, object of that class
can not be created. That is called as Abstract class.
constructors can not be inherited. Moreover, when this
class is inherited, the base class object can not be
created. So we can not create the derived class object
also.
the above ans is irrelevant to the current situation,
here the thing is, a constructor cannot b private coz there
is no use of .
but if a situation occurs as such in the given prob, yes the
space is reserved for that useless private constructor.
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
Re: When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory??
public class TrialClass
{
protected int i, j;
public TrialClass(int one, int two)
{
i = one;
j = two;
}
public TrialClass(int joo)
{
}
public int squareArea()
{
int side1;
int side2;
side1 = i;
side2 = j;
return side1 * side2;
}
}
public class myDerivedClass : TrialClass
{
int rd;
int dr;
public myDerivedClass(int Age, int ages):base(Age)
{
rd = ages;
dr = Age;
}
}
Try making the base class single parameterized constructor
private.You will get your answer.
sir i want to know which posting to apply since i am BE
CSE.. also want to know what are the rounds there for my
interview...Expecting for ur valuable answer....