首页 新闻 会员 周边

学习c++的新手遇到问题,求大神帮个忙

0
悬赏园豆:5 [已解决问题] 解决于 2018-07-21 08:59
我代码是这样的:
#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 cpp
Undefined symbols for architecture x86_64:
"result(int, int)", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [cpp] Error 1
make[2]: *** [CMakeFiles/cpp.dir/all] Error 2
make[1]: *** [CMakeFiles/cpp.dir/rule] Error 2
make: *** [cpp] Error 2

c++
dom树的主页 dom树 | 初学一级 | 园豆:-2
提问于:2018-07-21 00:02
< >
分享
最佳答案
0

你 result 函数定义呢?只有声明没有定义,怎么调用

收获园豆:5
Arthurian | 小虾三级 |园豆:1123 | 2018-07-21 08:29

谢谢,我弄明白了;谢谢,我看书上写的,但是书上没有定义函数;谢谢,非常感谢

dom树 | 园豆:-2 (初学一级) | 2018-07-21 08:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册