我正在写一堂课,这个疑问出现了。这是undef. 行为?另一方面,我不确定它是否被推荐,或者它是否是一个好的做法。如果我确保在 init 函数中不抛出异常,它是一个吗?
//c.h
class C{
float vx,vy;
friend void init(C& c);
public:
C();
};
//c.cpp
C::C()
{
init(*this);
}
void init(C& c) //throws() to ensure no exceptions ?
{
c.vx = 0;
c.vy = 0;
}
提前致谢