摘要:
// 默认实参.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; void showVolume(int length, int width = 1, int height = 1) ; int main(int argc, char* argv[]) { showVolume(4,6,8); showVolume(4,6); showVolume(4); r... 阅读全文
posted @ 2012-04-12 22:04
飞翔@骑士
阅读(92)
评论(0)
推荐(0)
摘要:
不允许根据形参的数目和类型之外的其他差异来重载。 1)仅是函数返回值不同,是不可以重载函数名的 2)不可以仅以const或传值调用和引用调用进行重载 当要返回类类型的成员变量时,一般需要返回常量类型(不能返回引用类型) class A { public: const some... 阅读全文
posted @ 2012-04-12 21:46
飞翔@骑士
阅读(133)
评论(0)
推荐(0)
摘要:
//值传递:替代形参的只是实参的值 //引用传递:传递的是变量(而不是变量的值)// (函数调用中的相应实参必须是变量) // input.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std ; void getInput(int num1, int num2) ; void showResults(int num1, int num2) ; int main(int ar 阅读全文
posted @ 2012-04-12 21:28
飞翔@骑士
阅读(160)
评论(0)
推荐(0)
摘要:
//number==0时,if语句中的return语句就会终止函数的调用以避免出现除数为0的情况 // voidReturn.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; //void函数中的return语句 // void icecreamDivision(int custormerNumber, double icecreamTotalWeight); int 阅读全文
posted @ 2012-04-12 20:56
飞翔@骑士
阅读(1229)
评论(0)
推荐(0)
摘要:
// roundNumber.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <cmath> using namespace std ; int roundNumber(double number) ; int main(int argc, char* argv[]) { double doubleValue ; char ans ; do{ cout <<" 阅读全文
posted @ 2012-04-12 20:34
飞翔@骑士
阅读(132)
评论(0)
推荐(0)
摘要:
cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); //小数点后保留2位小数 阅读全文
posted @ 2012-04-12 19:36
飞翔@骑士
阅读(203)
评论(0)
推荐(0)


浙公网安备 33010602011771号