typeid(arg).name()

J

josh

Hi, how can I read that program output?

template <typename T>
class OpSum
{
public:
OpSum(T a, T b) { x=a; y=b; }
T getSum() { return x+y; }

private:
T x, y;
};


int main()
{
OpSum<int> s(11,12);
OpSum<double> d(11,12);

cout << typeid(s).name() << "\n";
cout << typeid(d).name() << "\n";

return 0;
}5OpSumIiE
5OpSumIdE
 
S

Sylvester Hesp

josh wrote :
Hi, how can I read that program output?

template <typename T>
class OpSum
{
public:
OpSum(T a, T b) { x=a; y=b; }
T getSum() { return x+y; }

private:
T x, y;
};


int main()
{
OpSum<int> s(11,12);
OpSum<double> d(11,12);

cout << typeid(s).name() << "\n";
cout << typeid(d).name() << "\n";

return 0;
}
5OpSumIiE
5OpSumIdE

By looking at your screen with your eyes? I don't understand your
question. If you want to interpret the type names, read your compiler's
documentation or ask it in a relevant newsgroup. The C++ standard does
not specify what the output of name() should be (which makes your
quetion offtopic here), so it could be anything.

- Sylvester
 
I

Ian Collins

josh said:
Hi, how can I read that program output?

template <typename T>
class OpSum
{
public:
OpSum(T a, T b) { x=a; y=b; }
T getSum() { return x+y; }

private:
T x, y;
};


int main()
{
OpSum<int> s(11,12);
OpSum<double> d(11,12);

cout << typeid(s).name() << "\n";
cout << typeid(d).name() << "\n";

return 0;
}
5OpSumIiE
5OpSumIdE
It looks like you just have. Compilers are free to use whatever they
want for typeid names. Your output looks like gcc, so someone on a gcc
list might be able to help you decode it.

On my system, your code gives

OpSum<int>
OpSum<double>
 
J

josh

josh wrote :










By looking at your screen with your eyes? I don't understand your
question. If you want to interpret the type names, read your compiler's
documentation or ask it in a relevant newsgroup. The C++ standard does
not specify what the output of name() should be (which makes your
quetion offtopic here), so it could be anything.

- Sylvester

ok I post this msg to a G++ group!
 

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,294
Messages
2,571,511
Members
48,198
Latest member
couriermedicine

Latest Threads

Top