Reputation: 921
I have a class
class A{}
But I want to use macro to replace the class name A with the following statement:
#define SOMETHING A
The definition of class A {}
is in the same .cpp with the MACRO.
Does it correct?
I want to do this, because I am removing all of the MACRO in the source code. But the MACRO was used widely. Does any software could help me to do the replacement of MACRO ?
Upvotes: 2
Views: 1972
Reputation: 114578
Try #define A SOMETHING
. Then, if the preprocessor sees public class A
, it will presumably replace your class name to give public class SOMETHING
. Why in the world would you ever want to do such a thing though?
Upvotes: 1
Reputation:
Reverse the tokens; #define A SOMETHING
should work.
Note that it is a terrible idea as it may break other code and confuse the hell out of people.
Use an alias instead:
class A { … };
using SOMETHING = A;
Upvotes: 5