What happens when you attempt to compile and run the following code?
#include
using namespace std;
class First
{
public:
void Print(){ cout<<"from First";}
};
class Second:public First
{
public:
void Print(){ cout<< "from Second";}
};
void fun(First *obj);
int main()
{
First FirstObject;
fun(&FirstObject);
Second SecondObject;
fun(&SecondObject);
}
void fun(First *obj)
{
obj?>Print();
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A
{
public:
virtual void Print()=0;
};
class B:public A
{
public:
virtual void Print(){ cout<< "B";}
};
int main()
{
B ob2;
A *obj;
obj = &ob2;
obj?>Print();
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class Base {
int age;
public:
class C {
int b;
void PrintC() { cout << b; }
};
Base () {age=5;};
void setAge(int a=20) {age = a;}
void Print() { cout << age;}
};
int main () {
Base a;
a.setAge(10);
a.Print();
return 0;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A {
public:
void Print(){ cout<<"A";}
};
class C:public A {
public:
virtual void Print()=0;
};
int main()
{
C obj3;
obj3?>Print();
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int compare(int, int);
int main()
{
int x = compare(10, 20);
cout << x;
return 0;
}
int compare(int i, int j)
{
return i }