单选题

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
知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看