g++ 4.7.2
Hello,
I am coming from C89 and now I am doing c++ using g++ compiler.
Normally I do things like this:
#define ARR_SIZE 64
#define DEVICE "DEVICE_64"
What is the equivalent of doing this in C++?
Many thanks for any suggestions,
#define
is there in C++. So you can write the same code. But for constant quantities like this, it is better to use the const keyword.
const int ARR_SIZE = 64;
const std::string DEVICE("DEVICE_64");
You can use const
in place of #define
const int ARR_SIZE = 64;
const char DEVICE[] = "DEVICE_64";
You can define constants using the const
keyword:
const int ARR_SIZE = 64;
const char DEVICE[] = "DEVICE_64";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With