CPP Language / Classes and objects

Object-oriented programming (OOPS)uses objects in the programming languages. Object is a real world thing or entity. An object consists of State, Behavior and Identity.

Property Details Example
Identity It is the name of an object and enables one object to interact with other objects. Name of dog
State It is represented by attributes of an object. It also reflects the properties of an object. Breed, Age and color
Behavior It is represented by methods of an object. It also reflects the response of an object with other objects. Bark, sleep and eat

Class
It is a collection attributes / Instance Variables and methods.

Program Output

//Program used to print a text.
#include
using namespace std;
class a
{
public: string vn;
void fn()
{ cout << " vn is: " << vn; } };

int main()
{
a obj1;
obj1.vn = "Wisdom";
obj1.fn();
return 0;
}

Wisdom

Explanation: Class Name= a, Object Name= obj1;


Home     Back