有如下类的定义:class Constants{public:    static double GetPI(void){return 3.14159;}};Constants constants;下

7 查阅

有如下类的定义: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();