?
What will be the output of the following C++ code?
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class BaseClass
{
protected:
int i;
public:
BaseClass(int x)
{
i = x;
}
~BaseClass()
{
}
};
class DerivedClass: public BaseClass
{
int j;
public:
DerivedClass(int x, int y): BaseClass(y)
{
j = x;
}
~DerivedClass()
{
}
void show()
{
cout << i << " " << j << endl;
}
};
int main()
{
DerivedClass ob(3, 4);
ob.show();
return 0;
}
#include <iostream>
using namespace std;
class BaseClass
{
protected:
int i;
public:
BaseClass(int x)
{
i = x;
}
~BaseClass()
{
}
};
class DerivedClass: public BaseClass
{
int j;
public:
DerivedClass(int x, int y): BaseClass(y)
{
j = x;
}
~DerivedClass()
{
}
void show()
{
cout << i << " " << j << endl;
}
};
int main()
{
DerivedClass ob(3, 4);
ob.show();
return 0;
}
Join the Discussion
Login to post a comment or share your explanation.
Login