structure and a class

guys can you help me out what are the difference between a class and a structure?
1
2
3
4
5
6
7
8
9
struct S {
  /* by default, access is public unless explicitly stated otherwise via private: or protected: */
  int x;  // This is public by default
};

class C {
  /* by default, access is private unless explicitly stated otherwise via public: or protected: */
  int x;  // This is private by default
};

They are same except for the default access and inheritance.
EDIT: yes, default inheritance is public for structs and private for classes.
Last edited on
Topic archived. No new replies allowed.