![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 67
recording_gjl
这个作者很懒,什么都没留下…
展开
-
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 · 278 阅读 · 0 评论 -
c++计算数字字符串的和
问:输入11 22 333 444 字符串,计算出4个数相加的结果如何处理空格和数字转载 2017-12-10 17:40:35 · 2806 阅读 · 0 评论 -
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 · 801 阅读 · 0 评论 -
C++返回对象和返回引用
我们发现,在C++中,有些成员函数返回的是对象,而有些函数返回的又是引用。返回对象和返回引用的最主要的区别就是函数原型和函数头。Car run(const Car &) //返回对象Car & run(const Car &) //返回引用 返回对象会涉及到生成返回对象的副本,这事调用函数的程序可以使用的副本,因此,返回对象的时间成本包括了转载 2017-12-27 23:48:27 · 10045 阅读 · 0 评论 -
重载<<操作符
重载这个操作符使有理数的输出更方便,之后可以自己更改为任何类型的打印class Rational { private: int numerator; int denominator; friend ostream& operator(ostream& os,Rational r); //用以访问类的私有成员public:}ostream& op转载 2017-12-28 23:01:51 · 125 阅读 · 0 评论