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

后端 未结 30 3201
盖世英雄少女心
盖世英雄少女心 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 06:06

    Another main difference is when it comes to Templates. As far as I know, you may use a class when you define a template but NOT a struct.

    template // OK
    template // ERROR, struct not allowed here
    

提交回复
热议问题