Q: given char * const cp = ….; can you do cp = ‘b’
AA: yes. const is about the pointer (no rebinding), not the char pointee.
Q: can friend-class to Derived access Base protected field?
AA: yes in gcc
Q: what are the narrow-character iostream objects?
Q[u]: anything wrong with static_cast(MyClass var2)
%%A: This is a silly question. Bad coding style.
AA: illegal in gcc
Q[u]: if a ctor takes an int arg, can you call it with a char literal?
AA (confirmed): implicit conversion from char to int
Q: can a C struct be subCLASSed?
AA: yes struct differs from class in one way only
Q: if u catch by value, modify the exception object, then do an empty throw all within your catch block, then the does downstream catch the original or the modified object?
Q[u]: what’s wrong with
char * charArray = someString.c_str()
%%A (confirmed): c_str() returns a pointer to const char. Const radiates leftward
Q[u]: when you pass std::less to list.sort(), must you append “()” as “std::less()”?
AA: illegal without ().
%%A: std::less is a class, so we are instantiating it.
Q[u]: can catch(…) be the first among many catchers?
AA: must be last — illegal otherwise
Q[u]: a class template’s static function uses the T as parameter type. Callable without ?
AA: this follows the CLASS template instantiation rule, not the function template instantiation rule. No implicit detection by compiler. You must provide explicit type argument when referring to the class template
Q: bind1st or bind2nd on std::less when used as find_if() filter
AA: here’s the idiom. We are binding 2nd parameter to the literal 1000.
Note std::less is a Class template not function template, so the template type arg is mandatory.