首页 > 代码库 > similarity and difference between "struct" and "class"

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"