#undefine

Mar 1, 2011 at 7:20pm
Has like this undef define in c++?Such as:
 
#define inti int 

1
2
#undefine inti2 inti
cout<<typeid(inti2).name();

Mar 1, 2011 at 7:30pm
I don't know what you're trying to accomplish with that second set of code.. but you can undefine macros with the #undef command:

1
2
3
4
5
6
7
#define foo int

foo bar;  // same as int bar;

#undef foo  // foo no longer is defined

foo baz;  // compiler error, foo is not defined. 
Mar 1, 2011 at 7:32pm
I base to find invers define.I know #undef
Mar 2, 2011 at 12:13am
I don't understand what you mean. Can you clarify?
Mar 2, 2011 at 12:51am
Yeah. What do you mean by "inverse" define?
Mar 2, 2011 at 7:00am
Ok.
1
2
#define foo int
cout<<#undefined foo//#undefined or another transaction 

Output:
 
int
Mar 2, 2011 at 7:06am
Like this?
1
2
3
#define foo int
#define quote(x) #x
cout << quote(foo);
Last edited on Mar 2, 2011 at 7:07am
Mar 2, 2011 at 8:16am
No.What is the aggregation transaction's reverse?
Answer:Abstraction transaction.
I am finding define transaction reverse.I want to reverse define transaction.
Mar 2, 2011 at 8:59pm
It's very difficult to understand what you mean.

If you're not asking about #undef, then I don't know what you need.

Can you can give more examples of what you need?
Mar 2, 2011 at 9:19pm
I can't help but to think you are confused.
Mar 2, 2011 at 9:41pm
Zhuge's exam output:foo.I want to find startest variable (int).ok?
1
2
3
4
5
#define foo int
#(my transaction) abc foo
cout<<abc;
Output:
int
Mar 2, 2011 at 10:16pm
As for getting a string literal...for the preprocessor to expand the macro, it needs to not be inside of another macro (like quote()). But without the quote macro, you won't get a string literal and won't be able to cout it. You could do something semi-hackish like so, though:

1
2
3
4
#define foo int
#define abc foo
abc x; // x will be an int
std::cout<<typeid(x).name()<<std::endl;


This uses typeid(), though, which is non-standard (I think).
Mar 2, 2011 at 10:35pm
Yes.U apprehended me.
Mar 2, 2011 at 10:35pm
bully for you :)
Mar 2, 2011 at 10:37pm
U brainy person u:)
Topic archived. No new replies allowed.