字符串初步

有三种办法是用C++中的字符串:

1,C风格

  数组: char arrayString[20] = "Hello, World";

  指针: const char* pointString = "Hello, World";

  头文件:<cstring>

2,C++风格

  string类: string myString =  "Hello, World";

  C++ 类的好处是:可以直接是用运算符。

3,非标准风格

  如:MFC中的Cstring,目的是为了向后兼容或者处理遗留问题。

当开始一个C++项目时,提前决定如何表示字符串非常重要。

posted @ 2013-01-24 08:32  卧野观云  阅读(109)  评论(0)    收藏  举报