
C++
Amare丶
Amore a prima vista
展开
-
C++学习1 - 第一个C++程序
#include<iostream>using namespace std; //使用命名空间int main(){ cout //输出 Hello Zing! cout //输出3 cout //发出响铃 cout //换行 cout //制表符(tab) cout //输出\ cout //输出' cout //输出" cout //换行 sy原创 2017-06-08 11:32:12 · 194 阅读 · 0 评论 -
C++学习2 - 枚举型常量
#include<iostream>using namespace std;int main(){ enum day{sun,mon,tue,wed,thu,fri,sat}; day today; today = sat; if (today == sun || today == sat){ cout }else{ cout } system("pause");原创 2017-06-08 11:32:14 · 209 阅读 · 0 评论 -
C++学习3 - 定义一个对象
#include<iostream>using namespace std;class People{public: void getStature(){ cout } void getWeight(); void setStature(int x){ stature = x; } void setWeight(int y);private: int statur原创 2017-06-08 11:32:17 · 208 阅读 · 0 评论 -
C++学习4 - 内联函数
#include<iostream>inline int print(int);int print(int x){ return x;}int main(){ int x; cout cin >> x; cout << "输入的数字为:" << print(x) system("pause"); return 0;}内敛函数:用inline 来修饰原理:用函数pri原创 2017-06-08 11:32:20 · 158 阅读 · 0 评论 -
C++学习5 - const成员函数
#include<iostream>using namespace std;class A{public: void func(int x, int y){ i = x; j = y; } void print()const{ cout << "i*j="<<i*j }private: int i, j;};int main(){ A a; a.func原创 2017-06-08 11:32:22 · 170 阅读 · 0 评论 -
C++学习6 - 按值传递,按…
1.按值传递:#include<iostream>using namespace std;void swap(int a, int b){ int c; cout << "swap交换前,a:" << a <<"b:" c = a; a = b; b = c; cout << "swap交换hou,a:" << a <<"b:" }int main(){ int x原创 2017-06-08 11:32:27 · 213 阅读 · 0 评论 -
C++学习7 - 按别名传递对象
#include<iostream>usingnamespace std;class A{public: A(){ cout A(A&){ cout << "复制够造函数"<<endl;} ~A(){cout void set(int i){ x = i; } int get()const{ return x; }private: int x;};A& fun(A原创 2017-06-08 11:32:30 · 283 阅读 · 0 评论