您的位置:首页 > 编程语言 > C语言/C++

C++复习整理

2014-03-11 16:53 120 查看
#include<iostream>
using namespace std;
enum month {a, b=2 , c };
int main ()
{
cout<<a<<"  "<<b<<"    "<<c<<"\n";
system("pause");
return 0;
}


这个程序的输出结果是:

0 2 3

#include<iostream>
using namespace std;
int Fuc(int a)
{
cout<<a<<"\n";
return 0;
}
int main()
{
int (*fp)(int)=Fuc;//函数指针

fp(2);
system("pause");
return 0;
}


注意函数指针的用法

#include<iostream>
using namespace std;

int main()
{
char c='a';
char *p= &c;
cout<<*&c<<"\n";
cout<<*p<<"\n";
system("pause");
return 0;
}


输出结果:

a

a

注意这种写法也是对的。

#include<iostream>
using namespace std;

int main()
{
const int a=2,b=1;
int *p=&a;//此句会报错!
const int *p = &a;//同样错误
cout<<*p<<endl;
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: