similarity and difference between "struct" and "class"

Posted roadmap

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了similarity and difference between "struct" and "class"相关的知识,希望对你有一定的参考价值。

similarity:

1. struct is class, can declare, define field funcion

 struct Person {
    int age;
    int height;
    void SetAge(int age);
    int GetAge();
};

class Person {
    int age;
    int height;
    void SetAge(int age);
    int GetAge();
};

difference:

1. class default field is private, struct default field is public

以上是关于similarity and difference between "struct" and "class"的主要内容,如果未能解决你的问题,请参考以下文章

Difference between link and @import

difference bewteen *args and **args in python?

Difference between Netbios and Host name

Difference between hash() and id()

The difference between UDS on IP and UDS on CAN

The difference of Methods and Functions