【发布时间】:2020-03-21 09:54:06
【问题描述】:
我目前正在学习 C++,并在学习如何处理多个文件时遇到此编译器错误:
" 在函数main':
bravo.cpp:(.text+0x71): undefined reference tosum(int, int)'
collect2:错误:ld 返回 1 个退出状态“
我正在构建的代码是: 主要功能
#include<iostream>
#include "add.h"
int main(){
int a,b;
std::cout<<"Give me two numbers to add: \n";
//std::cin>>a>>b;
std::cout<<"The sum of two numbers is "<< sum(10,5)<< std::endl;
}
头文件
#pragma once
int sum(int a, int b);
求和函数
#include<iostream>
#include "add.h"
int sum(int a, int b){
return a+b;
}
那么我哪里做错了? 我尝试检查堆栈溢出错误,但我无法针对我的问题实施解决方案? 有任何想法吗? 谢谢。
【问题讨论】: