Posts

Introduction to OOP (Object Oriented Programming)

Introduction to OOP Object-oriented programming – As the name suggests uses objects in programming. Object Oriented Programming is defined as an approach that provides a way of modularising programs by creating a partitioned memory area for both data and functions that can be used as a template for creating copies of such modules on demand. Writing an OOP involves creating classes, creating objects from these classes, and creating applications that are stand-alone executable programs that use those objects. After being created, classes can be re-used over and over again, to develop new programs. Features of OOP Class : Class is a user defined data type. A class is a logical abstraction. It is a template that defines the form of an object. A class specifies both code and data. When defined class, you declare data that it contains, and the code that operates on the data. Data is contained in instance variable defined by the class known as data members and code is conta...

Classes and Object

Image
Introduction to Class and Object Class :  Class is a user defined data type. A class is a logical abstraction. It is a template that defines the form of an object. A class specifies both code and data. When defined class, you declare data that it contains, and the code that operates on the data. Data is contained in instance variable defined by the class known as data members and code is contained in functions known as member functions. The code and the data that constitute a class are called members of the class. Object : Object is a variable of a class. It is an identifiable entity with specific characteristics (data members) and behaviour (member functions). Defining an object is similar to defining a variable of any data type. Example - In the above example, as we can see, test is a class. This class has integer data member - num , and two member functions - void getdata() and void showdata(). Also, in the same program, we have t1 as a variable of class te...