我代码是这样的:
#include <iostream>
using namespace std;
int result(int, int);
const int k = 2;
struct Point{
int x , y;
};
int main() {
int z(0), b(50);
Point a;
cout << "输入两个整数(以空格区分):";
cin >> a.x >> a.y;
z = (a.x + a.y) * k;
z = result(z, b);
cout << "计算结果如下:" << endl;
cout << "((" << a.x << " + " << a.y
<< " ) * " << k << ")+" << b
<< "=" << z
<< endl;
return 0;
}
但是报错了:Scanning dependencies of target cpp[ 50%] Building CXX object CMakeFiles/cpp.dir/main.cpp.o[100%] Linking CXX executable cppUndefined symbols for architecture x86_64:"result(int, int)", referenced from:_main in main.cpp.old: symbol(s) not found for architecture x86_64collect2: error: ld returned 1 exit statusmake[3]: *** [cpp] Error 1make[2]: *** [CMakeFiles/cpp.dir/all] Error 2make[1]: *** [CMakeFiles/cpp.dir/rule] Error 2make: *** [cpp] Error 2
添加回答
举报
0/150
提交
取消