简体   繁体   English

C++ inheritance 中的运算符是什么意思?

[英]What does the : Operator mean in C++ inheritance?

I have been reading up on inheritance in C++ and noticed that我一直在阅读 C++ 中的 inheritance 并注意到

class Car: public Vehicle {
  public:
    string model = "Mustang";
};

You used a ":" operator before the defining the child class, however I couldn't find what this means.您在定义子 class 之前使用了“:”运算符,但是我找不到这意味着什么。

Is it just something we should know to use but not how it works or what it does?它只是我们应该知道使用的东西,而不是它的工作原理或作用吗?

The single colon could also signify class inheritance, if the class declaration is followed by : and a class name, it means the class derives from the class behind the single colon. The single colon could also signify class inheritance, if the class declaration is followed by : and a class name, it means the class derives from the class behind the single colon.

class InheritedClass : public BaseClass.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM