Company: Mathworks mcq
Difficulty: medium
What are the ways to stop name mangling in C++? Using extern "C" Using static keyword Using inline functions Using namespaces What is the output of the following C++ program? #include <iostream> using namespace std; class X { public: X() { cout << "X"; } ~X() { cout << "~X"; } }; class Y : public X { public: Y() { cout << "Y"; } ~Y() { cout << "~Y"; } }; int main() { Y obj; return 0; } XY~Y~X YX~X~Y XY~X~Y YX~Y~X What would be the output of the following C++ code snippet? #include <iostream> using namespace std; class A { public: int a; int b; A(int x, int y) : a(x), b(y) {} A(const A &Ain) { this->a = Ain.a; } }; int main() { A p(10, 11); A q(p); if (q.b) std::cout << "true"; else std::cout << "false"; return 0; } true false 11 Compilation Error What is the output for the following C++ program? #include <iostream> int main() { int i = 10; std::cout << "i"; return 0; } 10 i Error None of the above What is the output in