Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:58:44+00:00 2026-06-15T08:58:44+00:00

Possible Duplicate: typeid() returns extra characters in g++ I learned from cplusplus.com that typeid

  • 0

Possible Duplicate:
typeid() returns extra characters in g++

I learned from cplusplus.com that typeid function can get variable’s type infomation in C++. But the result is a bit strange in my machine.

For example:

#include <iostream>
#include <typeinfo>
#include <vector>
using namespace std;

class Test
{
};
int main()
{
    vector<int> v;
    vector<vector<int> > v2;
    Test t;
    cout<<"typeid for class Test: "<<typeid(t).name()<<endl;
    cout<<"typeid for vector<int>: "<<typeid(v).name()<<endl;
    cout<<"typeid for vector<vector<<int> >: "<<typeid(v2).name()<<endl;
    return 0;
}

After running this code, the output in my machine is:

typeid for class Test: 4Test
typeid for vector<int>: St6vectorIiSaIiEE
typeid for vector<vector<<int> >: St6vectorIS_IiSaIiEESaIS1_EE

I’m quite confused with the “4” before the class “Test” and the strange letters around the vector. Can anybody give me some explanations? Thank you!

My operating system is Fefora 17, g++ (GCC) 4.7.0 20120507 (Red Hat 4.7.0-5)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:58:45+00:00Added an answer on June 15, 2026 at 8:58 am

    typeid function can get variable's type infomation in C++

    It’s true, but when u call the type_info::name() function you get an unique name for each different type, but the standard does not guarantee that the name is somewhat meaningful.
    And it is also implementation-dependent.

    What you get in practice (at least for most/all implementation) is the mangled name of that type.

    In short, you can use type_info::name() only for comparison, or for debugging (and you’ll have to demangle the name by yourself to get something meaningful)

    EDIT
    Since you use gcc, you may want to check out this page: http://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: c# - How do you get a variable’s name as it was
Possible Duplicate: Jquery filter text boxes (Preventing user from inserting certain characters) I want
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: How can I get device ID for Admob My activity has a
Possible Duplicate: When can typeid return different type_info instances for same type? If I
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: Can a Bash script tell what directory it's stored in? Is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.