What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class complex{
double re, im;
public:
complex() : re(1),im(0.3) {}
complex(double n) { re=n,im=n;};
complex(int m,int n) { re=m,im=n;}
complex operator+(complex andt);
void Print() { cout << re << " " << im; }
};
complex complex::operator+ (complex andt){
complex temp;
temp.re = this?>re + t.re;
temp.im = this?>im + t.im;
return temp;
}
int main(){
complex c1(1),c2(2),c3;
c3 = c1 + c2;
c3.Print();
}
A. It prints: 1 1.5Which 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; };
A. 1What 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"; }
};
class C:public A {
public:
virtual void Print() { cout<< "C"; }
};
int main()
{
B ob2;
C ob3;
A *obj;
obj = andob2;
obj?>Print();
obj = andob3;
obj?>Print();
}
A. It prints: BCWhat is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input?
#include
#include
using namespace std;
void f();
int main()
{
f();
return 0;
}
void f()
{
char c;
c = cin.get();
cout << c;
if(c != '\n')
f();
}
A. It prints: helloThe following declaration: int i = 0b10;
A. is invalidWhat happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int x=0;
int *ptr;
ptr = andx;
cout< return 0; }
B. It prints address of ptr
C. It prints: 1
D. It prints: 2
What is the output of the program?
#include
#include
using namespace std;
int main()
{
string s1="Wo";
string s2;
s2 = s1;
string s3;
s3 = s2.append("rldHello");
cout << s3;
return( 0 );
}
A. It prints: WorldHelloWhat 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";}
};
int main()
{
A *obj;
A ob1;
obj = andob1;
obj?>Print();
B ob2;
obj = andob2;
obj?>Print();
}
A. It prints: ABWhat happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int x=20;
int *ptr;
ptr = andx;
cout<<*ptr;
return 0;
}
A. It prints: 20What happens when you attempt to compile and run the following code?
#include
using namespace std;
int x=5;
static int y;
int i=0;
void static myFunction()
{
y=x++ + ++i;
}
int main (int argc, const char * argv[])
{
x++;
myFunction();
cout< }
B. It prints: 5 5 0
C. It prints: 7 7 1
D. It prints: 6 5 1
Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPA-21-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.