implement all approprate member functions of a class
implement all approprate member functions of a class
For implementing appropriate all the member functions of the class -
For implementation basically 2 ways are there in which we can define and implement the member functions .
- First is inside of class definition
- And second one is outside of class definition
All the functions that are basically defined into the class which are treated as the inline function if the definition of function do not contains any kind of looping statements and any kind of the complex operations.
EXAMPLE -
#include <iostream>
using namespace std;
class happy
{
private:
int num;
public:
void get()
{
cout<<" please Enter number: "; cin>>num;
}
void show()
{
cout<<"Number is "<<num;
}
};
// main function starts
int main()
{
happy obj;
obj.get();
obj.show();
return 0;
}
Step by step
Solved in 3 steps with 1 images