a****l 发帖数: 245 | 1 class Alpha {
public:
char data[10000];
Alpha();
~Alpha();
};
class Beta {
public:
Beta() { n = 0; }
void FillData(Alpha a);
private:
int n;
};
How do you make the above sample code more efficient?
a. Make the constructor for Alpha virtual
b. Make the destructor for Alpha virtual
c. Change the return in FillData to int to negate the implicit return
conversion from "int" to "void"
d. pass a const reference to Alpha in FillData
e. If possible, make the constructor for Beta | k********n 发帖数: 1819 | 2 of course, pass by value cannot change the Alpha instance either. it should
be used to fill Beta members | a****l 发帖数: 245 | | P**********0 发帖数: 412 | 4 觉得应该选d.
【在 a****l 的大作中提到】 : 这么想就对了,谢谢!
|
|