【发布时间】:2015-04-21 03:24:57
【问题描述】:
我有 3 个 C++ 源文件,我需要从一个文件调用一个函数到另一个文件
getch.cpp
#include<stdio.h>
#include "getch2.h"
main()
{
char ch='x';
fun(ch);
}
getch2.cpp
#include<stdio.h>
void fun(char);
main()
{
}
void fun(char x)
{
printf("the ascii value of the char is %d",x);
}
func.h
void fun(char);
当我编译 getch2.cpp 时出现错误
C:\Users\amolsi\AppData\Local\Temp\cc1k7Vdp.o getch.cpp:(.text+0x18): undefined reference to `fun(char)'
C:\Users\amolsi\Documents\C files\collect2.exe [错误] ld 返回 1 个退出状态
【问题讨论】:
标签: c++ c header-files