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 is the expected result of the following program?
What happens if you try to compile and run this program?
#include
using namespace std;
int main (int argc, const char * argv[])
{
print("Test");
return 0;
}
void print(int c[])
{
cout< }
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A {
public:
int x;
A() { x=0;}
};
class B : protected A {
public:
int y;
using A::x;
B(int y) {this?>y = y;}
void Print() { cout << x << y; }
};
int main () {
B b(5);
b.Print();
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
const int size = 3;
class A {
public:
string name;
A() { name = "Bob";}
A(string s) { name = s;}
A(A &a) { name = a.name;}
};
class B : public A {
public:
int *tab;
B() { tab = new int[size]; for (int i=0; i B(string s) : A(s) { tab = new int[size]; for (int i=0; i ~B() { delete tab; } void Print() { for (int i=0; i cout << name; } }; int main () { B b1("Alan"); B b2; b1.tab[0]=0; b1.Print(); b2.Print(); return 0; }
What is the meaning of the following declaration? (Choose two.)
char **ptr;
What happens when you attempt to compile and run the following code?
Which of the following structures are correct?
1:
struct s1{
int x;
char c;
};
2:
struct s2{
float f;
struct s2 *s;
};
3:
struct s3{
float f;
in i;
}
What is the output of the program given below?
#include
using namespace std;
int main (int argc, const char * argv[])
{
float f=?10.501;
cout<<(int)f;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int x,y=10;
float f;
f = 5.90;
cout << f << ", ";
x=f;
cout << x <<", ";
f=y;
cout << f;
return 0;
}