51CTO博客开发龙哥技术成就梦想
typedef string* pstring; const pstring cstr; 请问,cstr是什么类型? 声明const pstring时,const修饰的
int main(int argc, char* argv[]) { int a=1,b=2; int &v1 = a; int
enum Point{ p1, p2, p3, p4 }; Point p = 2; //error ---> error C2440: 'initializing' : cannot convert from 'const int' to 'enum main::Point' Point pp = p2; //ok p3 = p4;
学习于《C++ Primer》 typedef 定义 从关键字 typedef 开始,后面跟 数据类型和标识符。 标识符只是 该数据类型的同义词,可以出现在 该数据类型出现的任何位置。 使用typedef, 一般出于3个目的: 1. 一个数据类型想用于多个目的; &n
C++支持struct, struct是从C中延续过来的。 C++中class与struct的区别在于 在默认情况下,如果不添加访问标号(public,protected,private)的话,class默认为private, struct默认为public. 举个例子:
STL下的vector是 模板类型,而不是数据类型。 所以 vector::size_type 是错的: for example: int main(int argc, char* argv[]) { vector::size_
(windows xp + VC6.0) 编译如下程序,初始化vector,在 容器中放入10个“hello”: #include "stdafx.h" #include <vector> using namespace std; int&n
cctype头文件中的部分函数: 测试如下: #include "stdafx.h" #include <iostream> #include <string> using namespace std; int
string::size_type 是 unsigned 型,所以它至少是signed 型的 2倍。 而 string 中的size() 返回值 为 string::size_type. 所以一些关于string或者 vector的size() 返回值的问题时,就必须用 string::size_type 比如: &n
测试发现 1. std::string value(2, ‘a’); 结果: value.size() == value.length()==2; value.capacity()==31  
《C++ Primer》 通过一个计数器和一个字符初始化string对象 std::string all_nines(5, ’9’); // all_nines=”99999”
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号