Inline Function in C++
Function Defintion Outside the Class and Use of Inline Keyword in C++:
Defining function outside the class with scope resolution(::) operator.
#include<iostream>
using namespace std;
class Maths
{
int num1,num2,res;
public:
void input();
void sum();
};
void Maths::input()
{
cout<<"Enter first number ";
cin>>num1;
cout<<"Enter second number ";
cin>>num2;
}
void Maths::sum()
{
res=num1+num2;
cout<<"\nResult is "<<res;
}
int main()
{
Maths mt;
mt.input();
mt.sum();
}
Output:
Enter first number 100
Enter second number 200
Result is 300