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;
class A {
public :
void print() {
cout << "A ";
}
};
class B {
public :
void print() {
cout << "B ";
}
};
int main() {
B sc[2];
B *bc = (B*)sc;
for (int i=0; i<2;i++)
(bc++)->print();
return 0;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
long int x,y=10;
double d;
d = 3.99;
x=(int) d;
cout << x <<", ";
d=float (y);
cout << d;
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A {
int x;
protected:
int y;
public:
int z;
A() { x=1; y=2; z=3; }
};
class B : public A {
string z;
public:
void set() { y = 4; z = "John"; }
void Print() { cout << y << A::z; }
};
int main () {
B b;
b.set();
b.Print();
return 0;
}