New course! Every coder should learn Generative AI!
Try a free lesson+ 4
Please help me in this...
https://code.sololearn.com/c699yKj5ysmA/?ref=app Why are there numbers along with the words?
6 Answers
+ 5
That is the way the compiler shows the typeid of variables. Each compiler will print different results.
I Think the P means a pointer. Try diferent types to find out the way the compiler describes types.
+ 5
As Ulisses hinted at, this is the result of "name mangling". It's used to differentiate between constructs of the same name during the compilation and linking process (consider function overloading, or having two constructs in different namespaces with the same names). How this happens is implementation-defined.
In this case, "P" indicates a pointer, and the number is simply the number of characters in the class name.
That's just how GCC chooses to do things. With MSVC, you get the following outputs:
class Base *
class Base *
class Base
class Derived
+ 4
I was searching on that and it looks like there is a way (a function) that prints more meaningfull information.
I did not read everything but maybe you will undertsand how to do that in this article:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html
+ 3
Why is there 4,7 in the output as well?
+ 3
@Ulisses Crus & @Squidy
Thank You!
Wow, GCC even counts the letters in the class name...
But what use can that be?
+ 3
Similarly:
On printing this:
long a;
cout<<typeid(a).name<<endl;
I get:
l //Just an l?