Category Archives: OOP with C++

30. Protected Access Modifiers

A protected member variable or function is very similar to a private member but it provided one additional benefit that they can be accessed in child classes which are called derived classes. You will learn derived classes and inheritance in next chapter. For now, you can check following example where I have derived one child class SmallBox from a… Read More »

29. Private Access Modifiers

The private Members A private member variable or function cannot be accessed, or even viewed from outside the class. Only the class and friend functions can access private members. By default all the members of a class would be private, for example in the following class width is a private member, which means until you label a member, it… Read More »

28. Public Access Modifiers

The public Members  All the class members declared under the public specifier will be available to everyone. The data members and member functions declared as public can be accessed by other classes and functions too. The public members of a class can be accessed from anywhere in the program using the direct member access operator… Read More »

27. Access Modifiers

Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type. The access restriction to the class members is specified by the labeled public, private, and protected sections within the class body. The keywords public, private, and protected are called… Read More »

26. Static class member

Static data member are class members that are declared using static keyword A static member has certain special characteristics These are: Only one copy of that member is created for the entire class and is shared by all the objects of that class , no matter how many objects are created. It is initialized to… Read More »

25. Namespace

Consider a situation, when we have two persons with the same name, Zara, in the same class. Whenever we need to differentiate them definitely we would have to use some additional information along with their name, like either the area, if they live in different area or their mother’s or father’s name, etc. Same situation… Read More »

24. What Is Class?

When you define a class, you define a blueprint for a data type. This doesn’t actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object. A class definition starts with the… Read More »

23. What is an object?

In C++, an Object is a real-world entity, for example, chair, car, pen, mobile, laptop, etc. In other words, object is an entity that has state and behavior. Here, state means data, and behavior means functionality. Object is a runtime entity, it is created at runtime. Object is an instance of a class. All the… Read More »

22. Object Oriented Programming

Procedural programming is about writing procedures or functions that perform operations on the data, while object-oriented programming is about creating objects that contain both data and functions. Object-oriented programming has several advantages over procedural programming: OOP is faster and easier to execute OOP provides a clear structure for the programs OOP helps to keep the… Read More »

21. Basic debugging skills

Debugging strategies Although there is no precise procedure for fixing all bugs, there are a number of useful strategies that can reduce the debugging effort. A significant part (if not all) of this process is spent localizing the error, that is, figuring out the cause of its symptoms. Below are several useful strategies to help… Read More »