Page 1 of 1

What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace

Posted: Wed Aug 03, 2022 9:20 am
by answerhappygod
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;b.print();}

A. It prints: Hello world
B. It prints: Hello
C. Compilation error
D. None of these