analogy.2
Senior Member
https://stackoverflow.com/questions...ifference-between-cbegin-and-begin-for-vectorMã:const std::vector<int> v; auto iter = v.begin();
TH này cái iter chỉ vào vật ko đổi thì nó là const_iter
vậy thì có khác gì cái TH dưới đây với cbegin? Cũng là const_iter ?
Mã:const std::vector<int> v; auto iter = v.cbegin();
begin sẽ trả về iter hoặc const_iter tùy vào specifier của thằng vector
Còn cbegin thì luôn trả về const_iter
Trong ví dụ trên thì theo mình hiểu 2 thằng ko khác gì nhau.
Còn ví dụ này thì khác nè:
Mã:
std::vector<int> v;
auto iter_c = v.cbegin(); //const_iter
auto iter = v.begin(); //iter

