
c++ 零散知识点
Jesse Kwok
See the results in two years!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
cin.get() cin.peek() 和cin>>i (i为char i[] 或者int) 的不同
cin.get() cin.peek() 和cin>>i (i为char i[] 或者int) 的不同*cin>>i(i为char i[] 或者int) 的不同#include <iostream>using namespace std;int main(){char a[30],i=0;while(cin原创 2018-09-10 22:13:33 · 330 阅读 · 0 评论 -
c++中 return语句的用法
c++ 中的return语句用于结束当前正在执行的函数,并将控制权返回给调用此函数的函数。return语句有两种形式:带返回值和不带返回值。 对于不带返回值的用法,不带返回值的return语句只能用于返回类型为void的函数,return语句是为了引起函数的强制结束,这种用法类似于循环结构中的break语句的作用。 对于带返回值的用法,其不能用于void类型的函数,否则报错。 ...原创 2018-09-14 12:47:35 · 5671 阅读 · 0 评论 -
函数模板 function template
函数模板 function template//错误代码#include <iostream>using namespace std;template <typename T>double add(T a,T b,T c){ return a+b+c;}int main(){ double result=add(2,2,2.5); cout<&l...原创 2018-10-15 20:27:20 · 390 阅读 · 0 评论 -
函数可以既作为重载函数,又作为有默认参数的函数
函数可以既作为重载函数,又作为有默认参数的函数重点:只有在函数调用上出现二义性时,才不行。例子如下:#include <iostream>using namespace std;void add(int a,int b,int c=0){ cout<<"a";}void add(int a,int b){ cout<<"b";}int ma...原创 2018-10-15 20:47:45 · 1499 阅读 · 0 评论 -
头文件的编写与使用
头文件的编写与使用原创 2018-10-15 20:48:32 · 1582 阅读 · 0 评论 -
指针的地址和指针指向的内存空间的地址
指针的地址和指针指向的内存空间的地址a &*a &a三者的不同:#include <iostream>using namespace std;int main(){ double *a=new double(100.0); cout<<a<<endl; cout<<&*a&l...原创 2018-10-20 11:40:02 · 1750 阅读 · 0 评论