问题在代码注释中,万分谢谢!如果能有针对性的提供参考资料或者书籍更好,谢谢!
demo.h
class A
{
protected:
int age;
public:
virtual void print();
A(int ); //问题一、函数参数只有类型没有函数参数?
~A();
};
class B : public A //问题二、冒号是什么意思?
{
public:
void print(); //问题三、print是哪个类型函数,不是构造函数吧?
//问题四,如果头文件引用了C的<stdio.h>,会冲突不?
B(int);
~B();
};
class C
{
private:
A a;
public:
C(A temp); //问题五、A temp 是什么?A是变量类型,temp是变量?
~C();
};
demo.cpp //问题六此文件的函数都是公开的还是私有的
A::A(int t):age(t)
{
cout << "constructor A!" << endl;
}
void A::print()
{
cout << "print A!" << endl;
}
A::~A()
{
cout << "destructor A!" << endl;
}
B::B(int t):A(t) //问题七、冒号是什么意思
{
cout << "constructor B!" << endl;
}
void B::print()
{
cout << "print B!" << endl;
}
B::~B()
{
cout << "destructor B!" << endl;
}
C::C(A temp):a(temp)
{
cout << "constructor C!" << endl;
}
C::~C()
{
cout << "destructor C!" << endl;
}