有如下类的定义:class Constants{public: static double GetPI(void){return 3.14159;}};Constants constants;下列各组语句中,能输出3.14159的是()
有如下类的定义:class Constants{public: static double GetPI(void){return 3.14159;}};Constants constants;下列各组语句中,能输出3.14159的是()
A.cout<<constants->GetPI();和cout<<Constants::GetPI();
B.cout<<constants.GetPI();和cout<<Constants.GetPI();
C.cout<<constants->GetPI();和cout<<Constants->GetPI();
D.cout<<constants.GetPI();和cout<<Constants::GetPI();
正确答案:cout<<constants.GetPI();和cout<<Constants.GetPI();
- 上一篇:有如下类的定义:Class MyClass{ int value;public: MyClass(int n):value(n){} int getValue() const {return value;}};则类Myclass的构造函数的个数是()
- 下一篇:有如下程序:#include iostreamusing namespace std;class VAC{public: int f() const{return 3;} int f(){return 5;}};int main(){ VAC v1; const VAC v2; coutv1.f()v2.f(); return 0;}运行时的输出结果是()