What is a Class and Object in C++?

前端 未结 20 1005
走了就别回头了
走了就别回头了 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 11:07

    A Class is like a blueprint, an object is like a house built from that blueprint.

    You can have many houses with the same layout/floorplan (read class), but each is it's own instance (read object). Each has it's own owner, furniture, etc.

    Note that there are also objects whose blueprint is not a class (e.g. integers).

提交回复
热议问题