萌新求教 救命啊
c++吧
全部回复
仅看楼主
level 13
狗gou富贵 楼主
3. 给出程序的输出结果,如有错误,请改正
#include <iostream>
#include<string>
using namespace std;
void print(const string &s1)
{
cout << "call for void print(const string &s1)" << endl;
cout << s1;
}
void print(string &s1)
{
cout << "call for void print(string &s1)" << endl;
cout << s1;
}
void print(string s1)
{
cout << "call for void print(string s1)" << endl;
cout << s1;
}
int main()
{
print("world");
return 0;
}
为什么const string &s1会和string s1一样?导致print过载
4. 给出程序的输出结果,如有错误,请改正
#include <iostream>
using namespace std;
float temp;
float area1(float r)
{
temp = r*r*3;
return temp;
}
float& area2(float r)
{
temp = r*r*3;
return temp;
}
int main()
{
float a1 = area1(5.0);
float& a2 = area1(5.0);
float& a3 = area2(5.0);
float a4 = area1(4) = 10;
float a5 = area2(4) = 20;
cout << a1 << endl;
cout << a2 << endl;
cout << a3 << endl;
cout << a4 << endl;
cout << a5 << endl;
return 0;
}
2018年03月26日 13点03分 1
level 13
狗gou富贵 楼主
dd
2018年03月26日 13点03分 2
👉编程自学教程,高清画质+系统教学,自己保存哦http://PAn.bAiDU.com/s/1nwi7V9f👈 ~~三个字打动我天涯海角我都跟你走
2018年03月26日 14点03分
level 13
狗gou富贵 楼主
dd
2018年03月26日 13点03分 3
1