3 回答
TA贡献1900条经验 获得超5个赞
class SuperClass{
public:
SuperClass(int foo)
{
// do something with foo
}};class SubClass : public SuperClass{
public:
SubClass(int foo, int bar)
: SuperClass(foo) // Call the superclass constructor in the subclass' initialization list.
{
// do something with bar
}};TA贡献1772条经验 获得超5个赞
class Sub : public Base{
Sub(int x, int y)
: Base(x), member(y)
{
}
Type member;};class Sub : public Base{
Sub(int x, int y)
try : Base(x), member(y)
{
// function body goes here
} catch(const ExceptionType &e) {
throw kaboom();
}
Type member;};TA贡献1804条经验 获得超8个赞
class A : public B{public:
A(int a, int b, int c);private:
int b_, c_;};A::A(int a, int b, int c)
: B(a), b_(b), c_(c) // initialization list{
// do something}- 3 回答
- 0 关注
- 865 浏览
添加回答
举报
