Skip to main content

Posts

C++ Constructors and Destructors

C++ Constructors and Destructors Providing the initial value as described in the earlier chapters of C++ does not conform to the philosophy of C++. So C++ provides a special member function called the constructor which enables an object to initialize itself at the time of its creation. This is known as automatic initialization of objects. This concept of C++ also provides another member function called destructor which is used to destroy the objects when they are no longer required. In this chapter, you will learn about how constructors and destructors work, types of constructors and how they can be implemented within C++ program. What are constructors? The process of creating and deleting objects in C++ is vital task. Each time an instance of a class is created the constructor method is called. Constructors is a special member functions of class and it is used to initialize the objects of its class. It is treated as a special member function because its name is the same as the class n

C++ Objects and Classes

C++ Object Oriented C++ Objects and Classes In object-oriented programming languages like C++, the data and functions (procedures to manipulate the data) are bundled together as a self-contained unit called an object. A class is an extended concept similar to that of structure in C programming language; this class describes the data properties alone. In C++ programming language, class describes both the properties (data) and behaviors (functions) of objects. Classes are not objects, but they are used to instantiate objects. What is a class? A class is an abstract data type similar to ‘ C structure ‘. Class representation of objects and the sets of operations that can be applied to such objects. Class consists of Data members and methods. Primary purpose of a class is to held data/information. This is achieved with attributes which is also know as data members. The member functions determine the behavior of the class i.e. provide definition for supporting various operations on data held

C++ Overloading

C++ Overloading C++ language allows programmers to specify more than one definition for a function name or an operator. This is one of the many exciting features that Object Oriented Language offers programmers. It is one of the important techniques that has extended the power and flexibility of C++. In this chapter you will learn about the types of overloading and how they are used within a C++ program. What is Overloading? Overloading is the technique to use a single identifier to define various methods or techniques of a class that differ in their input and output parameters. The concept of overloading is generally used when a program block conceptually execute the same task but with a slight distinctness in set of parameters. Overloading is a concept used to avoid redundant code where the same method name or operator is used multiple times but with a different set of parameters or number of operands. The actual method that gets called during runtime is resolved at compile time, thu

For Programs Click Here