How many instance variables does dObject have after the code in Line 26 is executed?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
using namespace std;
class BClass
{
public:
int x;
double y;
public:
virtual void print()
{
cout << "Result of additon: " << x + y << endl;
}
};
class DClass: public BClass
{
public:
void print()
{
cout << "Result of multiplication: " << x * y << endl;
}
};
int main ()
{
DClass *dObject;
BClass bObject;
dObject = new DClass;
dObject->x = 7;
dObject->y = 8;
bObject.x=10;
bObject.y=12;
dObject->print();
bObject.print();
}
|
Should be 0 right? Since *dObject should be holding a pointer variable and not object. But I'm really not sure.
1 and dObject is a pointer to it.
Topic archived. No new replies allowed.