根据下面的程序,可以在主程序中使用的合法语句是(  )。    #include <iostream>    using namespace std;    class Person{        int age;        voidtest(){}

admin2010-06-06  23

问题 根据下面的程序,可以在主程序中使用的合法语句是(  )。    #include <iostream>    using namespace std;    class Person{        int age;        voidtest(){}    public:        Person(intage){this->age=age;}        void ShowAge(){cout<<"the Person’s age is",<<age;}    };    void main(){        Person wang(23);    }

选项 A、wang.age=45
B、wang.wang(45)
C、wang.ShowAge()
D、wang.test()

答案C

解析 ShowAse是类的公有成员,可以由对象访问,其他的为私有成员,类对象不能访问。
转载请注明原文地址:https://kaotiyun.com/show/b5jp777K
0

相关试题推荐
最新回复(0)