CPA practice question 24 of 30

What happens when you attempt to compile and run the following code? #include #include using namespace std; struct Person { string name; int age; }…

Choose your answer, then check it against the explanation.

What happens when you attempt to compile and run the following code? #include #include using namespace std; struct Person { string name; int age; }; class First { Person *person; public: First() {person = new Person; person?>name = "John"; person?>age = 30; } void Print(){ cout<name << " "<age; } }; int main() { First t; t.Print(); }
Answer options
Question 24 of 30

Keep practicing

Take the free CPA practice test

Ten exam-style questions with answers and explanations, plus the exam facts and study guides.

Start the free practice test

More questions

Other CPA practice questions

Scroll to Top