c*e
2 楼
void log(std::string message);
class Account {
public:
Account(int id);
virtual ~Account();
virtual std::string get_name()=0;
int get_id();
};
Account::~Account() { log("Destroying: " + get_name()); }
What is the problem with the sample code above?
a) The + operator in the destructor is illegal because the types of its
operands are different.
b) Destructors are only allowed to delete memory. Calling log is illegal.
c) It is not possible to write a subclass of Account because Ac
class Account {
public:
Account(int id);
virtual ~Account();
virtual std::string get_name()=0;
int get_id();
};
Account::~Account() { log("Destroying: " + get_name()); }
What is the problem with the sample code above?
a) The + operator in the destructor is illegal because the types of its
operands are different.
b) Destructors are only allowed to delete memory. Calling log is illegal.
c) It is not possible to write a subclass of Account because Ac
i*g
3 楼
你都发了就行了,回不回有什么关系...
r*g
4 楼
so hard... i will guess e...
【在 c**********e 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: void log(std::string message);
: class Account {
: public:
: Account(int id);
: virtual ~Account();
: virtual std::string get_name()=0;
: int get_id();
: };
: Account::~Account() { log("Destroying: " + get_name()); }
: What is the problem with the sample code above?
【在 c**********e 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: void log(std::string message);
: class Account {
: public:
: Account(int id);
: virtual ~Account();
: virtual std::string get_name()=0;
: int get_id();
: };
: Account::~Account() { log("Destroying: " + get_name()); }
: What is the problem with the sample code above?
j*i
6 楼
It is not clear, seem only choice is e
but the statement is wrong, it is allowed to all get_name, but it will not
get the result you want, calling virtual function in the destructor and
constructor the vptr will not always point to corret class
【在 c**********e 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: void log(std::string message);
: class Account {
: public:
: Account(int id);
: virtual ~Account();
: virtual std::string get_name()=0;
: int get_id();
: };
: Account::~Account() { log("Destroying: " + get_name()); }
: What is the problem with the sample code above?
but the statement is wrong, it is allowed to all get_name, but it will not
get the result you want, calling virtual function in the destructor and
constructor the vptr will not always point to corret class
【在 c**********e 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: void log(std::string message);
: class Account {
: public:
: Account(int id);
: virtual ~Account();
: virtual std::string get_name()=0;
: int get_id();
: };
: Account::~Account() { log("Destroying: " + get_name()); }
: What is the problem with the sample code above?
i*g
7 楼
嗯,理解,看开就好了。
M*5
8 楼
这题答案是e
F*4
9 楼
我一般只发给chair 好像也没影响
h*6
10 楼
问题是,get_name是纯虚函数,这个类根本不允许有实例啊。
M*o
12 楼
You don't need to send a note to everyone.
相关阅读
没理由不认真工作 (转载)现代的女性真心不容易买卖提的bug? (转载)求加州软件公司内推【求助】关于简历和背景调查的问题求问湾区公司4年经验software dev的package下一次我打算尝试新的面试方式fb国内申请的曲折经历+电面想招个最好有Handwriting Recognition经验的Interntwo weeks notice 期间,会不会被fire?Globalfoundries这个公司怎么样?你们面试时候忽略了一个重要点没出过国的王自如的英语比不少北美猥琐男好多了吧不会回答挑衅性的问题晒一道有意思的面试题大家听说过tintri这个公司么如果在transfer前被原公司开除请教个面试题申请两个H1B 的问题Re: 烙印在职场上是不是很 rude? (转载)