Talk About Network

Google





Programming > C - C++ Learning > Re: A Question ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 4115 of 4400
Post > Topic >>

Re: A Question about ##

by "Xiutao Yang" <xiutao.yang@[EMAIL PROTECTED] > Apr 15, 2008 at 10:57 PM

sorry, it should be

void NEW(int i){
   CMyClass *a_i=new CMyClass();
   cout<<a_i->m_i<<endl

 }


"Xiutao Yang" <xiutao.yang@[EMAIL PROTECTED]
>
写入消息新闻:fu2fli$39m$1@[EMAIL PROTECTED]
> thx,all
> Now, I found the reason.
> void NEW(int i){
>    NEWW(i);
>    PPR(i);
> }
> wil be compiled as
> void NEW(int i){
>    CMyClass *a_##i=new CMyClass();
>   cout<<a_##i->m_i<<endl
>
> }
> Of course, It works well  :P
>
> thx again.
>
> "Ben Bacarisse" <ben.usenet@[EMAIL PROTECTED]
>
??????:874pa3jqhd.fsf@[EMAIL PROTECTED]
>> "Xiutao Yang" <xiutao.yang@[EMAIL PROTECTED]
> writes:
>>
>>>    I have a program about ## ,which is the following.
>> <snip>
>>
>>> #define F(i)   F_##i()
>>
>> <snip more pre-processor mangling>
>>
>>> The question is the I can call NEWW(i) in function void NEW(int i)
>>> But failed in processing function void FF(int i)?
>>> If we write void FF(int i) as:
>>> void FF(int i){
>>>     F(i);
>>> }
>>> It will fail.
>>
>> That is because FF(i) expands to F_i() and there is no F_i defined.
>> Presumably in NEWW(i) the value of i does not matter.  You seem to
>> want the pre-processor (which runs once when you program is built) to
>> know about the value of variables at run-time.  It just can't.
>>
>> Back up a bit and explain what you are doing and why you think this is
>> the right solution.
>>
>> -- 
>> Ben.
>
>
 




 6 Posts in Topic:
A Question about ##
"Xiutao Yang" &  2008-04-15 16:05:19 
Re: A Question about ##
Ian Collins <ian-news@  2008-04-15 20:09:01 
Re: A Question about ##
Ben Bacarisse <ben.use  2008-04-15 12:40:30 
Re: A Question about ##
"Xiutao Yang" &  2008-04-15 22:55:40 
Re: A Question about ##
"Xiutao Yang" &  2008-04-15 22:57:12 
Re: A Question about ##
"Xiutao Yang" &  2008-04-15 23:02:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 9:25:01 PST 2009.