About type_info and typeid

Source: Internet
Author: User

Different compilers return different results! For more information, see:

Http://www.cppblog.com/smagle/archive/2010/05/14/115286.html

/** File: Main. CPP * Author: Vicky. H * Email: eclipser@163.com */# include <iostream> # include <typeinfo> Class A {}; void fun1 () {// fvve F indicates function 1st V indicates function return void 2nd V indicates parameter void e indicates end ends STD: cout <"function" <STD :: endl;} const A * fun2 (INT, double, const int *, const double &) {return 0;}/***/INT main (void) {// typeid (/** can be a class, struct, common object type, object, pointer, function, function pointer, Int, double, and other data types */) // if n is returned, it indicates that the parameter is a class, struct, or public object. For example, 1a 4 Base indicates that a and base are classes, struct or public body // return PL start to indicate that the parameter is a class, struct, pointer object of the public body // return F Start to indicate that the parameter is a function, and the second return value is the return type of the function, then the parameter is the function transfer parameter type. e indicates the end. // fpk1aidpkirkde F indicates that the parameter is a function, P indicates a pointer, r indicates a reference, and K indicates a const, pk1a indicates that the return value is const a *, Id indicates that the function parameters are int and double, and PKI indicates that the parameter is const int *, rkd indicates that the parameter is const double & E, indicating end // then the function is const A * F (INT, double, const int *, const double &) {} // If PF is returned, the parameter indicates the function pointer STD: cout <typeid (INT ). name () <STD: Endl; STD: cout <typeid (const INT ). name () <STD: Endl; STD: cout <typeid (const Int &). name () <STD: Endl; STD: cout <typeid (double ). name () <STD: Endl; STD: cout <typeid (const double ). name () <STD: Endl; STD: cout <typeid (const double &). name () <STD: Endl; STD: cout <typeid (). name () <STD: Endl; STD: cout <typeid (const ). name () <STD: Endl; STD: cout <typeid (const &). name () <STD: Endl; STD: cout <"-------------------------" <STD: Endl; A; STD: cout <typeid (). name () <STD: Endl; STD: cout <typeid (). _ is_function_p () <STD: Endl; STD: cout <typeid (). _ is_pointer_p () <STD: Endl; STD: cout <"-------------------------" <STD: Endl; STD: cout <typeid (). name () <STD: Endl; STD: cout <typeid (). _ is_function_p () <STD: Endl; STD: cout <typeid (). _ is_pointer_p () <STD: Endl; STD: cout <"-------------------------" <STD: Endl; STD: cout <typeid (& ). name () <STD: Endl; STD: cout <typeid (& ). _ is_function_p () <STD: Endl; STD: cout <typeid (& ). _ is_pointer_p () <STD: Endl; STD: cout <"-------------------------" <STD: Endl; STD: cout <typeid (fun1 ). name () <STD: Endl; STD: cout <typeid (fun1 ). _ is_function_p () <STD: Endl; STD: cout <typeid (fun1 ). _ is_pointer_p () <STD: Endl; STD: cout <"-------------------------" <STD: Endl; STD: cout <typeid (fun2 ). name () <STD: Endl; STD: cout <typeid (fun2 ). _ is_function_p () <STD: Endl; STD: cout <typeid (fun2 ). _ is_pointer_p () <STD: Endl; STD: cout <"-------------------------" <STD: Endl; STD: cout <typeid (& fun2 ). name () <STD: Endl; STD: cout <typeid (& fun2 ). _ is_function_p () <STD: Endl; STD: cout <typeid (& fun2 ). _ is_pointer_p () <STD: Endl; return 0 ;}

 

I
I
I
D
D
D
1a
1a
1a
---------------------------
1a
0
0
---------------------------
1a
0
0
---------------------------
P1a
0
1
---------------------------
Fvve
1
0
---------------------------
Fpk1aidpkirkde
1
0
---------------------------
Pfpk1aidpkirkde
0
1

Run successfully (total time: 78 ms)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.