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
#include
using namespace std;
class A {
protected:
int y;
public:
int x, z;
A() : x(1), y(2), z(0) {}
A(int a, int b) : x(a), y(b) { z = x * y;}
void Print() { cout << z; }
};
class B : public A {
public:
int y;
B() : A() {}
B(int a, int b) : A(a,b) {}
void Print() { cout << z; }
};
int main () {
A b(2,5);
b.Print();
return 0;
}
What will the variable "y" be in class B?
class A {
int x;
protected:
int y;
public:
int age;
};
class B : protected A {
string name;
public:
void Print() {
cout << name << age;
}
};
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int i = 0;
do {
i++;
if (i==3)
break;
cout<
}
while(i < 5);
return 0;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
void print(char *c);
int main (int argc, const char * argv[])
{
print("Test");
return 0;
}
void print(char *c)
{
cout< }
Which of the following is a correct way to define the function fun() in the program below?
#include
#include
#include
using namespace std;
int main()
{
int a[2][2];
fun(a);
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class First
{
string *s;
public:
First() { s = new string("Text");}
~First() { delete s;}
void Print(){ cout<<*s;}
};
int main()
{
First FirstObject;
FirstObject.Print();
FirstObject.~First();
}