大家好,麻烦帮我看下下面三段程序哪里有问题?
大家好,麻烦帮我看下下面三段程序哪里有问题?namesp.h
#ifndef NAMESP_H_INCLUDED
#define NAMESP_H_INCLUDED
namespace pers
{
const int LEN=40;
struct person
{
char fname[LEN];
char lname[LEN];
};
void getperson(person &);
void showperson(const person &);
}
namespace debts
{
using namespace pers;
struct debt
{
person name;
double amount;
};
void getdebt(debt &);
void showdebt(const debt &);
double sumdebts(const debt ar[],int n);
}
#endif // NAMESP_H_INCLUDED
-----------------------------------------------------------
namesp.cpp
#include<iostream>
#include"namesp.h"
namespace pers
{
using std::cout;
using std::cin;
void getperson(person &rp)
{
cout<<"enter first name";
cin>>rp.fname;
cout<<"enter last name";
cin>>rp.lname;
}
void showperson(const person &rp)
{
std:ccout<<rp.lname<<","<<rp.fname;
}
}
namespace debts
{
void getdebt(debt &rd)
{
getperson(rd.name);
std::cout<<"enter debt:";
std::cin>>rd.amount;
}
void showdebt(const debt &rd)
{
showperson(rd.name);
std::cout<<":$"<<rd.amount<<std::endl;
}
double sumdebts(const debt ar[],int n)
{
double total=0;
for(int i=0;i<n;i++)
total +=ar[i].amount;
return total;
}
}
----------------------------------------------------------------
main.cpp
#include <iostream>
#include"namesp.h"
void other(void);
void another(void);
int main(void)
{
using debts::debt;
using debts::showdebt;
debt golf={{"benny","goetsniff"},120.0};
showdebt(golf);
//other();
//another();
return 0;
}
void other(void)
{
using std::cout;
using std::endl;
using namespace debts;
person dg={"doodles","glister"};
//howperson(dg);
cout<<endl;
//debt zippy[3];
int i;
for(i=0;i<3;i++);
//getdebt(zippy[i]);
for(i=0;i<3;i++);
//showdebt(zippy[i]);
//cout<<"Total debt:$"<<sumdebts(zippy,3)<<endl;
}
void another(void)
{
using pers::person;
person collector={"milo","rightshift"};
//pers::showperson(collector);
std::cout<<std::endl;
}
怎么通过不了编译。
提示main里的showdebt(golf);未定义 是什么原因啊?