有如下类定义: class Box{ public: double GetLength() { return length; } double GetWidth();

admin2021-02-22  13

问题 有如下类定义:
       class Box{
       public:
           double GetLength() { return length; }
           double GetWidth();
           double GetHeight();
       private:
           double length,width,height;
       };
       inline double Box::GetWidth() { return width; }
       double Box::GetHeight() { return height; }
在成员函数 GetLenth、GetWidth 和 GetHeight 中,内联函数有

选项 A、3个
B、2个
C、1个
D、0个

答案B

解析 在类体中定义的成员函数,C++系统会自动将它们作为内联函数处理,而在类外定义的成员函数,系统并不把它们默认为内联函数,使用inline也是内联函数,所以共有2个内联函数GetLength和GetWidth,B选项正确。
转载请注明原文地址:https://kaotiyun.com/show/oofp777K
0

最新回复(0)