inline funcitons

Hello, I made a function to change color in console using <windows.h> because it's name is too long.
Since its not recursive function, I used inline,
But I am not sure.
if you were me, what are you going to use, inline void or just void?



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <windows.h>
#include <cstdlib> // for system pause

using namespace std;
inline void usecolor(int i)
{
    SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), i);
    //	SetConsoleTitle("Color");

}

int main()
{
    	SetConsoleTitle("How to use colors in c++");

    cout << "Boring white text with black background" << endl ;
    usecolor(555);
    system("pause");
    usecolor(1) ; cout << "Now ";
    usecolor(2) ; cout << "this ";
    usecolor(3) ; cout << "is ";
    usecolor(4) ; cout << "what ";
    usecolor(5) ; cout << "I ";
    usecolor(6) ; cout << "call ";
    usecolor(7) ; cout << "programming ";
    usecolor(8) ; cout << "in ";
    usecolor(9) ; cout << "c";
    usecolor(10); cout << "++ " << endl ;
    usecolor(11) ; cout << "This ";
    usecolor(12) ; cout << "is ";
    usecolor(13) ; cout << "by ";
    usecolor(14) ; cout << "using ";
    usecolor(15) ; cout << "windows.h ";
    usecolor(16) ; cout << "library ";
    SetConsoleTitle("Was it simple?");
    return 0;
}

}
Last edited on
I think that there is no a difference because modern compiles can inline functions themselves.
Topic archived. No new replies allowed.