Question 17: Predict the output. (Considering int for 4 bytes)
class BaseClass
{
public:
int m_BaseData;
};
class DeriveClass : public BaseClass
{
public:
int m_DeriveData;
void printValues()
{
std::cout<<"\nBase Data : "<<m_BaseData;
std::cout<<"\tDerive Data : "<<m_DeriveData;
}
};
void BaseClassLoop (BaseClass *List, int Count)
{
int i;
for (i = 0; i < Count; ++i)
List[i].m_BaseData = i;
}
int main()
{
DeriveClass objList[2];
BaseClassLoop(objList,2);
for(int i =0;i< 2;i++)
{
objList[i].printValues();
}
}
Options:
(a) Base Data: 0 Derive Data: Garbage Value
Base Data: 1 Derive Data: Garbage Value
(b) Base Data: Garbage Value Derive Data: Garbage Value
Base Data: Garbage Value Derive Data: Garbage Value
(c) Base Data: 0 Derive Data: 1
Base Data: Garbage Value Derive Data: Garbage Value
(d) None of the above.
No comments:
Post a Comment