A simple c++ program using class and object
In this program, You will learn how to create a simple c++ program using class and object.
obj.msg();
obj.display();
Example: How to create a simple c++ program using class and object.
#include<iostream>
using namespace std;
class Test {
public:
void msg() {
cout << "msg function is called here";
}
void display() {
cout << "\ndisplay function is called here";
}
};
int main() {
Test obj;
obj.msg();
obj.display();
return 0;
}
Output:
msg function is called here
display function is called here