in the main function we are calling a 2 argument constructor,which in turn calls the bixbase constructor with the given parameters in the derived class object,so according to me the output of the program should be 200,but to my disappointment it is 100,plz explain!thnx in advance!
class BixDerived : public BixBase
{
public:
BixDerived ( int xx, int yy ) : BixBase ( xx, yy ) { }
};
You were creating two instances of your class item. One correctly, and one in the private section of your derived class that used the default constructor from your base class. You then called Show on the object that had been default constructed.
What is happening is that when you derive from a class, it is as if it is that class with some more added on top. This means that when you pass 10 and 20 to the constructor, it sets its own x and y values to be 10 and 20, respectively. However, objBase is another, different object, which is being default constructed with 10 and 10 instead.