What is a Class and Object in C++?

前端 未结 20 964
走了就别回头了
走了就别回头了 2020-12-09 10:33

What is a Class and Object in C++?

Can we say that a Class is an Object?

20条回答
  •  萌比男神i
    2020-12-09 11:14

    Class: A class defines a particular type's behaviours and properties.

    Object: An object is an instance of a class.

    For example, if you have a Dog named Bingo.

    • Dog would be the class defining its behaviours and properties

    • Bingo would be an object that is an instance of the Dog class

    Strictly speaking, a Class is not an Object in C++. But in languages such as C# and Java that supports reflection, classes can be used like objects but that is a more advance topic and probaly not what the original question is asking.

提交回复
热议问题