- 博客(7)
- 收藏
- 关注
原创 设计模式 0-Head First Design 目录
12章基本 14中设计模式 (也是14种设计方法,类如何写)Staregy PatternObserver PatternDecorator PatternFactory PatternSingleton PatternCommand PatternAdapter and Facade PatternTemplate Method PatternIterator and Composite ...
2018-06-24 17:28:07 132
转载 重载<<操作符
重载这个操作符使有理数的输出更方便,之后可以自己更改为任何类型的打印class Rational { private: int numerator; int denominator; friend ostream& operator(ostream& os,Rational r); //用以访问类的私有成员public:}ostream& op
2017-12-28 23:01:51 140
转载 C++返回对象和返回引用
我们发现,在C++中,有些成员函数返回的是对象,而有些函数返回的又是引用。返回对象和返回引用的最主要的区别就是函数原型和函数头。Car run(const Car &) //返回对象Car & run(const Car &) //返回引用 返回对象会涉及到生成返回对象的副本,这事调用函数的程序可以使用的副本,因此,返回对象的时间成本包括了
2017-12-27 23:48:27 10227
转载 c++计算数字字符串--函数重载
问:输入1个数,计算該数的平方,输入2个数,计算两个数的积输入3个数,计算3个数的和答:#include using namespace std;double calc(double value){ return value*value;}double calc(double value1, double value2)
2017-12-16 23:42:58 825
转载 c计算数字字符串的和
问:输入11 22 333 444 字符串,计算出4个数相加的结果答:#include #include int main(){ char s[100] = {0}; int ret=0;// gets(s); scanf("%[^\n]]",s); char *p = strtok(s," ");
2017-12-10 17:04:59 1011
原创 c++翻转字符串
问:“we;tonight:you” --> "ew;thginot;uoy"答:#include #include #include using namespace std;string func(const string& s,const char c){ unsigned int head = 0; unsigned int
2017-12-10 17:02:27 295
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人