ITPub博客

首页 > 应用开发 > > 学习c++的新手遇到问题,求大神帮个忙

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

作者:hawkliu 时间:2019-08-14 15:10:19 0 删除 编辑

我代码是这样的:

#include

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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/887/viewspace-3144477/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 使用session的问题
请登录后发表评论 登录
全部评论

注册时间:2019-07-29

  • 博文量
    274
  • 访问量
    1129