What are the differences between struct and class in C++?

后端 未结 30 3733
盖世英雄少女心
盖世英雄少女心 2020-11-21 05:38

This question was already asked in the context of C#/.Net.

Now I\'d like to learn the differences between a struct and a class in C++. Please discuss the technical d

30条回答
  •  没有蜡笔的小新
    2020-11-21 05:55

    There are 3 basic difference between structure and class

    1St- memory are reserved for structure in stack memory (which is near to programming language )whether for class in stack memory are reserved for only reffrence and actual memory are reserved in heap memory.

    2Nd - By default structure treat as a public whether class treat as a private .

    3Rd- can't re -use code in structure but in class we can re-use same code in many time called inhertence

提交回复
热议问题