What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class BaseClass{public:int *ptr;BaseClass(int i) { ptr = new int(i); }~BaseClass() { delete ptr; delete ptr;}void Print() { cout << *ptr; }};void fun(BaseClass x);int main(){BaseClass o(10);fun(o);
Answer(s): D
What will happen when you attempt to compile and run the following code?#include <iostream>using namespace std;int getValue();int main(){const int x = getValue();cout<<x;return 0;}int getValue(){return 5;}
Answer(s): C
What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class A {public:A() { cout << "A0 ";}A(string s) { cout << "A1";}};class B : public A {public:B() { cout << "B0 ";}B(string s) { cout << "B1 ";}};class C : private B {public:C() { cout << "C0 ";}C(string s) { cout << "C1 ";}};int main () {B b1;C c1;return 0;}
What is the output of the program?#include <iostream>#include <string>using namespace std;struct Person {int age;};class First{Person *person;public:First() {person = new Person;person?>age = 20;}void Print(){cout << person?>age;}};int main(){First t[2];for (int i=0; i<2; i++)t[i].Print();}
Answer(s): B
Post your Comments and Discuss C++ Institute CPA-21-02 exam with other Community members:
Subash Commented on December 10, 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
To protect our content from bots for real learners like you, we ask you to register for free. Sign in or sign up now to continue with the CPA-21-02 material!