cara ash
cara ash

Reputation: 127

typeid gives types m, j and Pj

I'm trying to understand a piece of code and came across this

    size_t max = 3;
    unsigned trial {3};
    auto* primes { new unsigned[max] };

I read that when you define something like unsigned int trial {3}; you get an int that can it's only positive. But this unsigned variables doesn't specify the type. So I tried to know what type they are with this:


    cout << typeid(max).name() << endl;
    cout << typeid(trial).name() << endl;
    cout << typeid(primes).name() << endl;

But got this weird output

m
j
Pj

What's going on here?

Upvotes: 1

Views: 2505

Answers (1)

Jonas Bystr&#246;m
Jonas Bystr&#246;m

Reputation: 26129

unsigned is short for unsigned int.

The strings returned from typeid::name are implementation-specific.

Since you seem to be on some Linux system, probably demangling could help you along: stdc++ demangling.

Upvotes: 2

Related Questions