Whats the point of #define?

I heard of something called Preprocessor Directives or something, and i wrote this

#include <iostream>

using namespace std;

int main()
{

#define lol 35.4

cout << lol << endl;






system("pause");
}

Whats the point of it? its literally the same thing as declaring an int. Is there an actual purpose of it that makes it better than declaring a regular variable?

ALSO if you guys are wondering why i use system("pause");, return 0 does not work. Any ideas?
its literally the same thing as declaring an int


Almost the same as declaring a double.

Is there an actual purpose of it that makes it better than declaring a regular variable?


It's better to declare a const variable:

const double lol = 35.4;

or in c++11, a constexpr:

constexpr auto lol {35.4};

The #define can be used to make macros, but that is not generally recommended either.

Oh, return 0; returns a 0 to the OS, to signal the program ended well. This is handy for scripts where the running of a command is dependent on the successful completion of a previous command.

On the beginners forum there is a stickied topic dedicated to console closing down earlier than desired.

Also, an article:

http://www.cplusplus.com/articles/iw6AC542/
Thank you
Topic archived. No new replies allowed.