My understanding towards c++ is still shallow hence i can't fully understand how to fully use typeid() even if looking at msdn and cppreference. Any help is appreciated :)
When using typeid(), typing ".name()" behind it seems like a must rather than optional,
1. So why is ".name()" needed when using typeid()?
I do note that "." is used with ".name()",
2. So is "." a member access of object? If not, what is it?
The bracket in "name()" indicates that you can put something inside
3. does it have any use since i've only seen references with "name()" bracket being left out.
The typeid operator returns an object of type std::type_info. You can compare two std::type_info objects using == or != to check if the types are the same. I have never found a use for it myself but I guess it could be useful with templates.
The name function is indeed a member function of the std::type_info class. In order to call the function you need to use parentheses, as with all functions. It returns an implementation-defined name of the type so don't expect the names to be the same on two different compilers.
Note that I had to use a reference here because std::type_info can't be copied.
2. Why does typeid() in typeid().name(), an object has parenthesis, doesnt it make typeid() a function?
Techically typeid is an operator, but it doesn't really matter for the discussion if it was a function. The important thing is that it returns an object of type std::type_info.