Oct 16, 2013

[c++] Naive note for beginner (or cursorily programmer)

Compiler will lookup for a object's attribute as
1. variable
2. function

3. use typename will consider as a type
4. if it's a template, use template<T> name

C++11:
auto as a return value of function does not behave the same as auto variable declaration.

 
auto HA() ->decltype(T()) {}

auto must be plain type 'auto', can't be used as auto&& deduced type:
 
const int a;
auto& tmp_1 = a; // reference to const int
auto tmp_2 a; //auto is type int

difference between name and expression:
 
struct Test
{
int tmp;
};
const Test t;
decltype(t.tmp) tmp; // tmp is type int
decltype((t.tmp)) tmp; // tmp is type const int&

also:
Why does C++ require a user-provided default constructor to default-construct a const object?

POD:
POD Type
What are Aggregates and PODs and how/why are they special?

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.