软件是dev_c++
小弟开成三个档
分别是
// lab1-1.h
namespace Complex{
typedef struct{
double real;
double image;
}Cplex;
const double pi = 3.1416;
void showComplex(const Cplex &m);
}
// lab1-1.cpp
#include <iostream>
#include "lab1-1.h"
namespace Complex{
void showComplex(const Cplex &m)
{
std::cout << m.real;
if (m.image < 0)
std::cout << m.image << "i" << std::endl;
else
std::cout << "+" << m.image << "i" << std::endl;
}
}
// lab1-1-main.cpp
#include <iostream>
#include "lab1-1.h"
using namespace Complex;
int main()
{
Cplex n;
n.real = 1 * pi;
n.image = -0.5;
showComplex(n);
return 0;
}
会出现
C:\Users\T12034~1\AppData\Local\Temp\cccfgPBD.o lab1-1-main.cpp:(.text+0x31):
undefined reference to `Complex::showComplex(Complex::Cplex const&)'
C:\document\collect2.exe [Error] ld returned 1 exit status
不知道该怎么修改
救命啊!!