为什么我定义头文件的时候会错误?(2)
  • 板块灌水区
  • 楼主yinxiangbo2030
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/9/9 09:23
  • 上次更新2023/11/2 22:13:50
查看原帖
为什么我定义头文件的时候会错误?(2)
1005576
yinxiangbo2030楼主2023/9/9 09:23

rt,显示ld returned 1 exit status和main.cpp:(.text+0xe): undefined reference to sayhello()'

代码:

//hello.h
#ifndef HELLO_H
#define HELLO_H
void sayhello();
#endif

//hello.cpp
#include<iostream>
#include"hello.h"
void sayhello(){
	std::cout<<"hello";
}

//main.cpp
#include"hello.h"
using namespace std;
int main(){
	sayhello();
	return 0;
}
2023/9/9 09:23
加载中...