hi all.im new to this forum.
ive got a problem with this program:
it seems the "virtual" word changes something in my program and instead of getting 100 from print function i get 43-million-something.Code:class X {
public:
X() { }
X( int xx ) : x( xx ) { }
int getx() const { return x; }
private:
int x;
};
class Y : virtual public X {
public:
Y( int xx ) : X( xx ) { }
};
class Z : public Y {
public:
Z( int xx ) : Y( xx ) { }
};
int main()
{
Z zobj( 100 );
cout << zobj.getx() << endl;
i have been trying to find some reference of virtual and what it does but i seem to be unlucky up till now.
any help would be much appreciated,thank you.
