单选题
有如下程序: #inc1ude<iostream> using namespace std; c1ass Boat; c1ass Car{ public: Car(int i):weight(i){} friend int Total(const Car &c,const Boat &b); //① private: int weight; }; c1ass Boat{ public: Boat(int i):weight(i){} friend int Total(const Car &c,const Boat &b); private: int weight; }; int Total(const Car &c,const Boat &b){ //② return c.weight+b.weight; } int main0{ Car c(10), Boat b(8); cout<<"The totalweightis "<<Total(c,b)<<end1; //③ returnO; }下列关于程序的描述中,正确的是( )。
【正确答案】
A
【答案解析】解析:程序中定义了类Car和类Boat,在两个类中分别定义他们的构造函数和友元函数friend。程序在VC6.0中编译通过。