Sir*_*lot 3 c# c++ inheritance constructor
我来自C#背景,我会写一个类和构造函数,如下所示:
public class Grunt : GameObject
{
public Grunt()
: base()
{
// do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
如何在C++中编写构造函数继承?在标题和源中.我知道你没有'base'关键字可以使用,但其他语法是否相同?
class Grunt : public GameObject
{
Grunt()
: GameObject() // Since there are no parameters to the base, this line is actually optional.
{
// do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
并强烈考虑在The Definitive C++ Book Guide and List中获得一本优秀的C++书籍
| 归档时间: |
|
| 查看次数: |
136 次 |
| 最近记录: |