本文共 1290 字,大约阅读时间需要 4 分钟。
记录c++学习中的小知识点.
1.输入输出#includeusing namespace std;/************************//* 这是第一个c++程序*//************************/int main(){ cout<<"hello world"<< " yunlan"; cout< > x; cout << oct << x < > y; cout << boolalpha << y << endl; system("pause"); return 0;}
2.命名空间
#include#include using namespace std;/************************//* 命名空间*//************************/namespace mynum{ int x = 105;}int main(void){ bool isflag = false; if(mynum::x % 2 == 0) { isflag = true; } else { isflag = false; } if(isflag) { cout << "偶数" << endl; } else { cout << "基数" << endl; } system("pause"); return 0;}
3.引用
#include#include using namespace std;/************************//* 引用*//************************/int main(void){ /*基本数据类型的引用*/ int a = 3; int &b = a; b = 10; cout << "a="< << endl; /*指针的引用*/ int c = 10; int *p = &c; int *&q = p; *q = 20; cout << "c="<< c <
4.堆内存、ram
#include#include using namespace std;/************************//* 堆内存,ram*//************************/int main(void){ int a = 10; int *p = &a; cout<<*p<<","< <
转载地址:http://qsnci.baihongyu.com/