User Tools

Site Tools


notes:cprog:spring2024:projects:cppx

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
notes:cprog:spring2024:projects:cppx [2024/04/17 19:10] – [C++ compiler] amelvil2notes:cprog:spring2024:projects:cppx [2024/04/17 19:17] – [Access Control] amelvil2
Line 155: Line 155:
  
 Class members declared as ''public'' can be used by any function. Class members declared as ''public'' can be used by any function.
 +
 +<code>
 +class MyClass {
 +public:
 +    int publicMember;
 +};
 +</code>
  
 ===Private=== ===Private===
  
 Class members declared as ''private'' can be used only by member functions and friends (classes or functions) of the class. Class members declared as ''private'' can be used only by member functions and friends (classes or functions) of the class.
 +
 +<code>
 +class MyClass {
 +private:
 +    int privateMember;
 +};
 +</code>
  
 ===Protected=== ===Protected===
Line 164: Line 178:
 Class members declared as ''protected'' can be used by member functions and friends (classes or functions) of the class. Additionally, they can be used by classes derived from the class. Class members declared as ''protected'' can be used by member functions and friends (classes or functions) of the class. Additionally, they can be used by classes derived from the class.
  
 +<code>
 +class MyClass {
 +protected:
 +    int protectedMember;
 +};
 +</code>
 =====Objects===== =====Objects=====
  
notes/cprog/spring2024/projects/cppx.txt · Last modified: 2024/04/24 16:23 by amelvil2