首页 > 其他 > 详细

Namespace, string, vector and array

时间:2014-10-03 18:12:05      阅读:282      评论:0      收藏:0      [点我收藏+]

1. Headers should not include using declaration

Code inside headers ordinarily should not include using declarations. The reason is that the contents of a header are copied into the including program‘s text. If a header has a using declaration, then every program that includes that header gets the same using declaration. As a result, a program that does not intend to use the specified library name might encounter unexpected name conflicts.

2. Deal with characters in string( with functions in <cctype> header)

  isalnum(c): true if c is a letter or digit

  isalpha(c): true if c is a letter

  isdigit(c): true if c is a digit

  islower(c): true if c is a lowercase letter

  isspace(c): true if c is a whitesapce

  isupper(c): true if c is an uppercase letter

  tolower(c): return lowercase letter

  toupper(c): return uppercase letter

3. Different between pointer and iterator

Pointer is a built-in type whereas iterator is a class. Pointer is avaiable for all type of objects whereas iterator is only available for containers.

4. Vector and array

Similarity: they all store a collection of variables of a single type and we can access their element by position. 

Difference: elements in array is stored in continuous space whereas elements in vector can be stored in non-continuous space. Array is fixed size and we can‘t add or remove element from a array. On the contrary, the size of a vector can be changed by adding or removing elements from it.

4. There is no arrays of references

 

Namespace, string, vector and array

原文:http://www.cnblogs.com/Kai-Xing/p/4005075.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!