Structure default access modifier
Structure in C++ has been taken from C programming language and C does not support any OOP concept. All member variables and member functions are thus accessible from outside world.
In a C++ structure type, the default access modifier for class member and member functions is "public". We need not to provide the keywork "public" in the class definition but that is default taken by the compiler.
Public members are the class members (data members and member functions) that are open to the outside world. The public function members implement the concept of interfaces in object oriented programming.
Structure default access without "public"
Structure default access with "public"
The above two programs can compile fine since having "public" keyword or not is same for the compiler.
$ g++ struct.cpp
About our authors: Team EQA
You have viewed 1 page out of 62. Your C++ learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Memory leaks Best Hosting plans, 80% discounts