辅导案例-COMP 3023

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
/HOME  MY COURSES  COMP 3023  ASSESSMENT  PRACTICE EXAM
Information
Question 3
Not yet
answered
Marked out of
1.00
Read through the following code then answer the questions below:
#include
#include
using namespace std;
class PracticeExam {
public:
PracticeExam(string grade) : _grade{grade} {
cout << " +" << _grade;
}
~PracticeExam() {
cout << " -" << _grade;
}
private:
friend ostream& operator<<(ostream &out, const PracticeExam &e);
string _grade;
};
ostream& operator<<(ostream &out, const PracticeExam &e) {
return out << ' ' << e._grade;
}
int main()
{
cout << "Grades:";
PracticeExam e1{"HD"};
PracticeExam *e2{&e1};
PracticeExam *e3{new PracticeExam{"C"}};
{
PracticeExam &e4{*e3};
cout << *e2;
PracticeExam e5{"D"};
cout << e4;
}
delete e3;
return 0;
}
Enter the output of the above code in the box below:

/Path: p
Question 4
Not yet
answered
Marked out of
10.00
Briefly explain why the above code produces the output that it does.
It may help to briefly explain what is happening for each line of code in the 'main' function.
Font family Font size Paragraph

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468