Re: Getting the type of a variable?

From: Richard Herring (junk_at_[127.0.0.1)
Date: 10/25/04


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


Relevant Pages

  • Re: Indirect referencing in VB6
    ... > literal variable names and somehow use them to point to the value. ... > programmer before I was a VB programmer so I must have been thinking of ... >> indirection and procedure calls in traditional languages. ...
    (microsoft.public.vb.general.discussion)
  • Re: Find and write
    ... When you, or others, advocate approaches or ideas that differ from those ... >I am sure Norman, however at the end of the day learning basic spreadsheet ... >through solid spreadsheeting skills than macro writing. ... > It's just my humble opinion, I did not say the macro was complicated. ...
    (microsoft.public.excel.programming)
  • Help - Why did my vis basic formula stop working
    ... same.I also copied and changed the sources to new cells ... off somehow? ... When I reopened the excel file a "macro ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Large (1000+ pages) document - Break into many individual files
    ... alter that macro at the first link to break the documents out where MyStyle ... A graphic logo appears at the top of what needs to become the new ... Somehow name and save the new smaller files. ...
    (microsoft.public.word.docmanagement)
  • Re: Test for Corrupt Excel File
    ... that somehow the format is changed during the cut/paste. ... function via a macro, perhaps you could incorporate the copy/paste function ... "Excel files" created by a dump from the company's main computer. ...
    (microsoft.public.excel)