Answer Posted / debashis mishra,india,orissa
if an object of a derived class is assigned to a base class
object,the compiler accepts it.but it copies only the base
portion of the object
class base
{
public:
int i,j;
};
class derived : public base
{
private:
int k;
};
int main()
{
base b;
derived d;
b=d;
return o;
}
here b contains i and j where as d contains i,j&k.On
assignment only i and j of the d get copied into i and j of
b. k doesnot be copied. on the effect object d got sliced.
| Is This Answer Correct ? | 46 Yes | 6 No |
Post New Answer View All Answers
What is advantage of inheritance?
What is class in oop with example?
What is class and example?
write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.
design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)
What is the difference between encapsulation and polymorphism?
What are the benefits of polymorphism?
What does and I oop mean?
Why do we need oop?
What is pointer in oop?
write a programe to calculate the simple intrest and compund intrest using by function overlading
What is meant by oops concept?
What are the benefits of interface?
what is the drawback of classical methods in oops?
What is the main purpose of inheritance law?