Skip to main content

Posts

Showing posts with the label dot operator

Classes and Objects

C++ is an object oriented language. An object oriented language works on the principle of objects - which contain within themselves data and functions which modify this data. Objects are created with the help of classes. Let us what are these classes first. Classes A class is a code template from which objects are created. A class defines what data members an object must have and what functions it must have.  An object has a state and behavior similar to real life object. State is data of the object. Behavior is what it can do. e.g. if we consider a pencil - it has state - what is color, length, diameter etc. It has behavior - it can write.  A class defines what are these state and behavior.  In programming paradigm class is similar to data type and object is a variable of this type. Or object is one instance of this class. Defining a class  A class is defined using the keyword class followed by its name and followed by class members within b...