Posts

Showing posts from June 10, 2018

Namespace in C++

Namespace A program includes many identifiers defined in different scopes. Sometimes an identifier of one scope will overlap (i.e. collide) with an identifier of the same name in a different scope, potentially creating a problem. Identifier overlapping also occurs frequently in third-party libraries that happen to use the same names for global identifiers (such as functions).

Objects as Function Arguments in C++ Programming | C++ Programming

Objects as Function Arguments Like any other data type, an object may be used as a function argument in three ways: pass-by-value, pass-by-reference, and pass-by-pointer.

Class and Object and Memory in C++ Programming | C++ Programming

Image
Class and Object and Memory in C++ Programming   When a class is specified, memory space of all the member function is allocated but memory allocation is not done for the data member.   When an object is created, memory allocation for its data members is done. The logic behind separate memory allocation for member functions is quite obvious. All instances of a particular class would be using the same member functions but they may be storing different data in their data members.   Memory allocation for objects is illustrated in fig below Class and Object and Memory in C++ Programming It can be observed that “n” objects of the same class are created and data members of those objects are stored in distinct memory location, whereas the member functions of object 1 to object n are stored in the same memory area. Therefore, each object has a separate copy of data members and the different objects share the member functions among them.