My Blog List

C++ Qualifiers

Volatile 

Have been told in the last post "C++"

Const

const variable cannot modify the value by the program
const member function cannot modify the data in the class

Static

  • variable inside a function: only it is initialized it remains in the memory until the end of program
  • In the class: a static class variable or static class method. All the instances share one variable or static. It doesn't require a instance of class to exist. It can be called by class rather than instance.

Public vs Protected vs Private

  • public : can be accessed by anyone
  • private: can be accessed only by member functions and friends of the class
  • protected: can be accessed by member functions and friends of the class and derived classes

Friend

  • A non-member function can access the private and protected members of a class if it is defined as a friend of that class
  • A class can access the private and protected members of a class if it is defined as a friend of that class

No comments:

Post a Comment

Enter you comment