What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class A {public:A() { cout << "A no parameters";}A(string s) { cout << "A string parameter";}A(A &a) { cout << "A object A parameter";}};class B : public A {public:B() { cout << "B no parameters";}B(string s) { cout << "B string parameter";}};int main () {A a2("Test");B b1("Alan");B b2(b1);return 0;}
Answer(s): B
What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class A {public:string s;A(string s) { this?>s = s; }};class B {public:string s;B (A a) { this?>s = a.s; }void print() { cout<<s; }};int main(){A a("Hello world");B b=a;
Answer(s): A
What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int op(int x, int y);int main(){float *pf;float f=0.9;pf=&f;cout << op(1, *pf);return 0;}int op(int x, int y){return x*y;}
What happens when you attempt to compile and run the following code?#include <iostream>#include <string>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();}
Answer(s): C
Post your Comments and Discuss C++ Institute CPA-21-02 exam with other Community members:
Subash commented on October 21, 2024 I am planning to take this exam. Are these 257 questions enough to clear it? Also, does each section have a passing percentage, or is it based on the overall ? INDIA upvote
Our website is free, but we have to fight against bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the CPA-21-02 content, but please register or login to continue.