C/C++
「已注销」
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
数组名为常指针,与数组第一个元素地址相同
#include //数组名为常指针,与数组第一个元素地址相同void main(){ int k[10];coutfor(int i=1;icoutcoutchar * p="abcd"; coutchar q[10]="wert";cout}原创 2016-09-08 08:33:01 · 383 阅读 · 0 评论 -
指针
#include void main(){int sum=0;int k[100];int * p;for(int i=1;i{ k[i-1]=i-1;} p=k+5; //指向k[5]int x=*p; printf("k[5]=%d \n",x);//输出k[5]//测试*--px=*--p;//p先减1即指向k[4] 然后*p赋值翻译 2016-09-08 08:20:45 · 243 阅读 · 0 评论 -
函数重载与模板
#include//定义函数模板template T max(T x, T y) {return x>y ? x:y;}void main() { cout cout}原创 2016-09-08 08:40:32 · 352 阅读 · 0 评论 -
静态变量
#include using namespace std;int i = 0;int fun(int n){ static int a = 2;a++;return a+n;}int main(){int k = 5; //对于代码块里面的变量只在代码块内有效{int i = 2;k += fun(i);//k=k+fun(i)原创 2016-09-08 08:52:19 · 531 阅读 · 0 评论 -
引用
#include void main(){ int x=100;int & m=x;x=m++; coutcoutif(x==100) coutelse cout}原创 2016-09-08 08:56:20 · 268 阅读 · 0 评论 -
Swap的比较
#include void swap1(int a,int b){ int c=a; a=b;b=c;}void swap2(int * a,int * b){ int * c=a; a=b;b=c;}void swap3(int * a,int * b){ int c=*a; *a=*b;*b=c;}void swap4(int原创 2016-09-08 08:58:22 · 298 阅读 · 0 评论 -
typedef的用法
#include //在编程中使用typedef目的一般有两个,一个是给变量一个易记且意义明确的新名字,另一个是简化一些比较复杂的类型声明struct student{int age;int no;} s1,s2;typedef struct student my;typedef int myint; int main(){ my q1; my原创 2016-09-08 09:11:47 · 263 阅读 · 0 评论 -
类成员的4种使用方式
#include class student{public: int no; void show(){cout };int main(){ student s1;//对象 s1.no=1;s1.show(); student & x=s1;//引用 x.no=4;x.show();原创 2016-09-08 09:16:54 · 507 阅读 · 1 评论
分享