单选题 有如下程序: #include #include using namespace std; class MyBag{ public: MyBag(string br,string cr):brand(br),color(cr) { ++count; } ~MyBag() { --count; } static int GetCount() { return count; } private: string brand,color; static int count; }; int MyBag::count=0; int main(){ MyBag one("CityLife","Gray"),two("Micky","Red"); _____________________ return 0; } 若程序运行时的输出结果为 2,则横线处缺失的语句不可能是
【正确答案】 B
【答案解析】解析:本题考查静态数据成员和静态成员函数,静态成员函数只能使用本类中的静态数据成员,且静态成员函数不归属任何一个对象,而是属于类,题目中要求输出2,那么就要将count输出,题目中定义了两个对象,都对count进行了++,所以调用静态成员函数直接使用类名,B选项正确。