100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

CPA AnswerSheet Programming Essentials in C++ Chapter 6 Assessment

Rating
-
Sold
-
Pages
12
Grade
A+
Uploaded on
02-09-2022
Written in
2021/2022

CPA AnswerSheet Programming Essentials in C++ Chapter 6 Assessment

Institution
Module









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Module

Document information

Uploaded on
September 2, 2022
Number of pages
12
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

CPA Chapter 6 Assessment Answers 100%
1. What happens when you attempt to compile and run the
following code?
#include <iostream>
using namespace std;

class X {
private:
int v;
};

class Y : public X {
Y() : v(0) {}
}

int main() {
Y y;
cout << y.v;
return 0;
}

 It prints -1
 It prints 0
 It prints 1
 Compilation fails
2. What happens when you attempt to compile and run the
following code?
#include <iostream>
using namespace std;

class X {
protected:
int v;
};

class Y : protected X {
Y() : v(0) {}
}

int main() {
Y *y = new Y();
cout << y->v;
delete y;
return 0;
}

,  It prints -1
 It prints 0
 Compilation fails
 It prints 1
3. What happens when you attempt to compile and run the
following code?
#include <iostream>
using namespace std;

class X {
public:
int v;
void put(int x) { v = x; }
int get(void) { return v; }
};

class Y : public X {
public:
Y() { put(0); }
void write(int x) { put(x + 1); }
int read(void) { return get() – 1; }

};

int main() {
Y *y = new Y();
y->write(1);
cout << y->read();
delete y;
return 0;
}

 It prints -1
 Compilation fails
 It prints 1
 It prints 0
4. What happens when you attempt to compile and run the
following code?
#include <iostream>
using namespace std;

class X { };
class Y : public X { };
class Z : public X { };

int main() {
Z *z = new Z();
$4.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
arviemontemayor

Also available in package deal

Get to know the seller

Seller avatar
arviemontemayor AMACC
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
3 year
Number of followers
0
Documents
39
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions