Which of the structures is incorrect?
1:
struct s1{
int x;
long int li;
};
2:
struct s2{
float f;
struct s2 *s;
};
3:
struct s3{
float f;
struct s3 s;
};
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A {
public:
void Print(){ cout<<"A"; }
};
class B:public A {
public:
virtual void Print(){ cout<< "B"; }
};
class C:public B {
public:
void Print(){ cout<< "C"; }
};
int main()
{
A ob1;
B ob2;
C ob3;
A *obj;
obj = &ob1;
obj?>Print();
obj = &ob2;
obj?>Print();
obj = &ob3;
obj?>Print();
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int op(int x, int y)
{
int i;
i = x + y;
return i;
}
int main()
{
int i=1, j=2, k, l;
k = op(i, j);
l = op(j, i);
cout<< k << "," << l;
return 0;
}
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:
void Print(){ cout<< "from Second";}
};
int main()
{
Second t[2];
for (int i=0; i<2; i++)
t[i].Print();
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A {
public :
void print() {
cout << "A ";
}
};
class B {
public :
void print() {
cout << "B ";
}
};
int main() {
B sc[2];
A *bc = (A*)sc;
for (int i=0; i<2;i++)
(bc++)->print();
return 0;
}