Which is the correct&nbspoutput of t...
发布于 2022-03-03 17:30:35
Which is the correct output of the following program.
#include <iostream> #include <string> using namespace std class ObjectCount{ private: static int objCount public: ObjectCount() { objCount++ } static void print(const string& msg = "") { if(msg.size() != 0) cout << msg << ": " cout << "objCount = " << objCount << endl } ~ObjectCount() { objCount-- } } int ObjectCount::objCount = 0 ObjectCount f(ObjectCount oc) { return oc } int main(){ ObjectCount o1 ObjectCount::print("after construction of o1") ObjectCount o2 = f(o1) ObjectCount::print("after call f()") }
登录后免费查看答案
关注者
0
被浏览
10