In C++, how can I change the type with another name
For example
How can I declaring an object real which would be the same as declaring it float
In C++, how can I change the type with another name
For example
How can I declaring an object real which would be the same as declaring it float
Are you referring to typedef ?
typedef float real;
int main(int argc, char **argv)
{
real val = 10.1;
return 0;
}
--ahamed
Yes. I have a lot of programs and classes in various files and I have created
common.h
The contents are
#ifndef Common_hh
#define Common_hh
#include <stdlib.h>
typedef float Real;
#endif
Then I include it with the #include in the files
Is your question answered then, or is there more to it?
I have defined a function in a class called GetFloat and want to be able to call it using GetReal. Is this possible for class functions?
Using g++ I use the compiler option
-DGetReal=GetFloat
I want now to have it in the actual code
If that already works, it's equivalent to #define GetReal GetFloat
It's a global text replacement that only matches whole words, essentially, so would match a bare GetFloat nearly anywhere, including the class you want, and anywhere else you don't want too.
The usual way to change the name of a function in C++ would be to change the name of the function. Or if you really need both names, create an inline wrapper so it has two names.
float getReal(void) { return(value); }
inline float GetFloat(void) { return(GetReal()); }