Say I have this code
std::string s = "hello";
std::string* p = &s;
int l = p.length();
Visual Studio and CLion know dot operator is incorrect. Actually when I press key ., both IDE commit the keystroke as ->
.
Since C++ is typed, it knows p is a pointer, why doesn't it combine . and -> into one?
Can the syntax be to always use .
, if p is pointer, dereference it first, otherwise directly get its member?