What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code?
#include #include using namespace std;
class SampleClass
{ string *s; public:
SampleClass() { s = new string(“Text”);}
SampleClass(string s) { this?>s = new string(s);} ~SampleClass() { delete s;}
void Print(){ cout<<*s;} }; int main() { SampleClass *obj; obj = new SampleClass("Test"); obj?>Print(); }
A. It prints: Text
B. It prints: Test
C. It prints: TextTest
D. Garbage value.

Download Printable PDF. VALID exam to help you PASS.

Posted in: CPA

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.