Amazon上最搞笑的物品评论# Joke - 肚皮舞运动
h*g
1 楼
class A
{
public:
void f{};
protected:
A(){};
A(const A&){}
}
Referring to the sample code above, why are the default and copy
constructors declared as protected?
A.
To ensure that instances of A can only be created by subclasses of A
B.
To ensure that instances of A cannot be created via new by a more derived
class
C.
To ensure that instances of A cannot be copied
D.
To ensure that A cannot be instantiated on the stack
E.
To ensure that A cannot be used as a base class
答案给的是A。 那如何由子类去创造 A 的object 呢?A * p= new subclass 可行吗?
能call A的ctr吗?
{
public:
void f{};
protected:
A(){};
A(const A&){}
}
Referring to the sample code above, why are the default and copy
constructors declared as protected?
A.
To ensure that instances of A can only be created by subclasses of A
B.
To ensure that instances of A cannot be created via new by a more derived
class
C.
To ensure that instances of A cannot be copied
D.
To ensure that A cannot be instantiated on the stack
E.
To ensure that A cannot be used as a base class
答案给的是A。 那如何由子类去创造 A 的object 呢?A * p= new subclass 可行吗?
能call A的ctr吗?