Re: Getting the type of a variable?
From: Richard Herring (junk_at_[127.0.0.1)
Date: 10/25/04
- Next message: Patrick: "Static Variable running init"
- Previous message: Chris \( Val \): "Re: Reading a file from a specified range"
- In reply to: CG: "Re: Getting the type of a variable?"
- Next in thread: Old Wolf: "Re: Getting the type of a variable?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 25 Oct 2004 17:56:03 +0100
In message <417d1f14$0$18025$a729d347@news.telepac.pt>, CG
<gamac@megamail.pt> top-posted
>"fotzor" <steven11@gmx.de> wrote in message
>news:44291922.0410221103.32f30fbe@posting.google.com...
>> Hi,
>> is it somehow possible to get the type of a variable in a macro?
>> example:
>>
>> #define SOME_MACRO(x) // what's the type of x???
>>
>> i guess the type-information is lost but i can't use a template here
>
>You can use the typeid operator.
>
>For instance:
>
>///////////////
>class Car;
>
>Car x = new Car();
>
>cout << typeid( x ).name() << endl;
>///////////////
>
>Should output "Car"!
>
Or almost anything else :-(
According to 18.5.1 the result is merely "a name for the type", and is
otherwise unspecified and may differ between programs.
-- Richard Herring
- Next message: Patrick: "Static Variable running init"
- Previous message: Chris \( Val \): "Re: Reading a file from a specified range"
- In reply to: CG: "Re: Getting the type of a variable?"
- Next in thread: Old Wolf: "Re: Getting the type of a variable?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|