An object is an entity or instance of class. each object has properties and behaviors.
Example
// C++ program to demonstrate
// accessing of data members
#include <bits/stdc++.h>
using namespace std;
class Geeks
{
// Access specifier
public:
// Data Members
string geekname;
// Member Functions()
void printname()
{
cout << “Geekname is: ” << geekname;
}
};
int main() {
// Declare an object of class geeks
Geeks objName;
// accessing data member
objName.geekname = “zee”;
// accessing member function
obj1.printname();
return 0;
}
Leave a Comment