Inline function: You can make a function inline by writing the keyword inline before defining the function.
C++ programming code
using namespace std;
int check_digit(char);
int main() {
char c;
cout << "Enter a character\n";
cin >> c;
if ( check_digit(c) ) {
cout << c << " is a digit.\n";
}
else {
cout << c << " isn't a digit.\n";
}
return 0;
}
inline int check_digit(char c) {
if ( c >= '0' && c <= '9' ) {
return 1;
}
else {
return 0;
}
}
C++ programming code for inline function using class
using namespace std;
class programming {
char c;
public:
void input();
void output();
};
inline void programming::input() {
cin >> c;
}
void programming::output() {
cout << c << endl;
}
int main() {
programming object;
object.input();
object.output();
return 0;
}