04 2015 档案

摘要:申明指针,并分配内存:typeName *pointName = new typeName;int *int_ptr = new int;释放:delete int_ptr;int *ints_ptr = new int[10];释放:delete [] ints_ptr;1 int *in... 阅读全文
posted @ 2015-04-14 16:04 扑通
摘要:头文件:#include 1 double divideNumbers(double a,double b) 2 { 3 if(b==0) 4 { 5 throw std::exception("No zero"); 6 } 7 return a/b... 阅读全文
posted @ 2015-04-07 11:18 扑通
摘要:std::vector 是矢量数组,可以自动增长,头文件:#include std::array C++11中新型容器,需要指定数组的长度,头文件:#include 。 1 vector vInts; 2 for(int i=0;i::const_iterator iterator ... 阅读全文
posted @ 2015-04-07 11:01 扑通
摘要:C++的另一种for循环写法,和C#的foreach语法很类似,不需要知道数组的类型;C++:for(auto& item:items)C#:foreach(var item in items) 1 int ages [10] = {0}; 2 //常规for循环 3 for... 阅读全文
posted @ 2015-04-07 09:40 扑通