Inline and outline functions
Inline and outline functions are the functions which are defines as follows :
1. Inline functions:
Any function which is defined and declared in a particular class then it is known as an Inline functions.
These inline functions are very much useful in writing a program implicitly without any errors.
2. Outline functions:
Any function which is declared inside a class but the definition of that particular declaration is outside a class is known as Outline functions.
These Outline functions are very useful to declare and define a function explicitly without errors.
This Inline and Outline functions are only possible in which object oriented programming is possible where we can create yen number of classes and objects here.
Now let us consider an Example where we can see both the inline and outline functions program:
INLINE FUNCTIONS:
//Inlinefunctions.cpp
#include<iostream>
using namespace std;
class Account
{
private:
char name[50];
long int Acc_no;
public:
void input() {
cout<<"Enter your name and account number"<<endl;
cin>>name>>Acc_no;
}
void output() {
cout<<"\n Oh! You have a account"<<endl;
cout<<"Your name and account number you have entered is"<<name<<Acc_no<<endl;
}
};
int main() {
Account a;
a.input();
a.output();
return 0;
}
The above shown is the output screen of my computer using command prompt.
2. OUTLINE FUNCTIONS:
//Outlinefunctions.cpp
#include<iostream>
using namespace std;
class Account
{
private:
char name[50];
long int Acc_no;
public:
void input();
void output();
};
void Account::input() {
cout<<"Enter your name and account number"<<endl;
cin>>name>>Acc_no;
}
void Account::output() {
cout<<"\n Oh! You have a account"<<endl;
cout<<"Your name and account number you have entered is"<<name<<Acc_no<<endl;
}
int main() {
Account a;
a.input();
a.output();
return 0;
}
0 Comments