Question: Consider the following code snippet: ` ` ` class BaseClass { public: BaseClass ( ) ; virtual void set _ data ( int new _

Consider the following code snippet:
```
class BaseClass
{
public:
BaseClass();
virtual void set_data(int new_data1);
private:
int data1;
};
BaseClass::BaseClass()
{
data1=0;
}
void BaseClass::set_data(int new_data1)
{
cout "BaseClass set_data" endl;
}
class DerivedClass : public BaseClass
{
public:
virtual void set_data(int new_data1);
};
void DerivedClass::set_data(int new_data1)
{
cout "DerivedClass set_data" endl;
}
int main()
{
BaseClass* bs1= new BaseClass;
DerivedClass* ds1= new DerivedClass;
bs1= ds1;
bs1->set_data(20);
return \theta;
}
```
What is the output?data1\(=20\) is the output.
BaseClass set_data is the output.
DerivedClass set_data is the output.
There is no output because there are compilation errors.
Consider the following code snippet: ` ` ` class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!