C++ questions

B

BCC

Hi,

Is there any way in c++ to:
1. Convert a variable name to a string: int m_x; if (converttostring(m_x) ==
"m_x") {}

or

2. Have an array or vector with pointers or addresses of different primitive
types (ints, doubles, floats, etc.)

I dont think so but thought I would check...

Thanks,
B
 
L

Larry Brasfield

BCC said:
Hi, Greetings.

Is there any way in c++ to:
1. Convert a variable name to a string: int m_x; if (converttostring(m_x) == "m_x") {}

No, not in any way that should be called "in C++".
You can, of course, imagine any sort of processing
to be done upon source files to achieve such a result.
2. Have an array or vector with pointers or addresses of different primitive types (ints, doubles, floats, etc.)


You can have an array or vector of void *, elements of
which can point to any data type. Or the elements could
be a union of whatever typed pointers you like.
 
V

Victor Bazarov

BCC said:
Is there any way in c++ to:
1. Convert a variable name to a string: int m_x; if (converttostring(m_x)
== "m_x") {}

#define converttostring(x) std::string(#x)

But why do you think you need that?
or

2. Have an array or vector with pointers or addresses of different
primitive types (ints, doubles, floats, etc.)

I dont think so but thought I would check...

No to this one.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,055
Members
47,658
Latest member
jaguar32

Latest Threads

Top