摘要:
#include <iostream> #include <string> using namespace std; class Student { public: Student(const string& name1, int age1, int no1) { name = name1; age 阅读全文
摘要:
隐试类型转换: char c = 'A'; int x = c; //隐试类型转换 cout << x << endl; 显式类型转换: //强制类型转换 char c = 'A'; int x = (int)c; //C风格 int y = int(c);//C++风格 C++扩展了四种操作符形式 阅读全文
摘要:
#include <iostream> using namespace std; inline int add(int a, int b = 10) { //inline 内联函数--可以提高执行效率 //内联函数和普通函数的区别在于:当编译器处理调用内联函数的语句时,不会将该语句编译成函数调用的指 阅读全文
摘要:
#include <iostream> using namespace std; int add(int a, int b = 10) { //b=10 缺省参数,缺省参数必须在右侧 //如果函数的声明和定义分开写,缺省参数只需写在声明部分就行,定义部分就不需要写了 return a + b; } 阅读全文