What is a Class and Object in C++?

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

What is a Class and Object in C++?

Can we say that a Class is an Object?

20条回答
  •  悲哀的现实
    2020-12-09 10:49

    An object is some data, which has an address in run-time memory.

    There are different types of object (e.g. int, float, etc.). You can create user-defined types, called 'classes'.

    For example, I can define Dog as a class ...

    class Dog {};
    

    ... and then create several objects, each of which is one instance of that class ...

    Dog fido;
    Dog spot;
    

提交回复
热议问题