namesp.h

 #pragma once
#include <string> namespace pers
{
using namespace std;
struct Person
{
string fname;
string lname;
};
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);
}

namesp.cpp

 #include "namesp.h"
#include <iostream> using namespace std; void pers::getPerson(Person & rp)
{
cout << "Enter first name: ";
cin >> rp.fname;
cout << "Enter last name: ";
cin >> rp.lname;
} void pers::showPerson(const Person & rp)
{
cout << rp.fname << ", " << rp.lname;
} void debts::getDebt(Debt & rd)
{
getPerson(rd.name);
cout << "Enter debt: ";
cin >> rd.amount;
} void debts::showDebt(const Debt & rd)
{
showPerson(rd.name);
cout << ": $" << rd.amount << endl;
} double debts::sumDebts(const Debt ar[], int n)
{
double total = ;
for (int i = ; i < n; i++)
{
total += ar[i].amount;
}
return total;
}

namessp.cpp

 #include <iostream>
#include "namesp.h" void other(void);
void another(void); int main()
{
using debts::Debt;
using debts::showDebt; Debt golf = { {"Benny","Goatsniff"},120.0 };
showDebt(golf);
other();
another(); std::cin.get();
return ;
} void other(void)
{
using namespace std;
using namespace debts; Person dg = { "Doodles","Glister" };
showPerson(dg);
cout << endl; Debt zippy[];
int i;
for (int i = ; i < ; i++)
{
getDebt(zippy[i]);
}
for (i = ; i < ; i++)
{
showDebt(zippy[i]);
}
cout << "Total debt: $" << sumDebts(zippy, ) << endl;
return;
} void another(void)
{
using pers::Person;
Person collector = { "Milo","Rightshift" };
pers::showPerson(collector);
std::cout << std::endl;
}

最新文章

  1. AJAX POST&amp;跨域 解决方案 - CORS
  2. web前端工程师在移动互联网时代里的地位问题
  3. java session 详解
  4. B450黑苹果之路(1)
  5. Atitit.HTTP&#160;代理原理及实现&#160;正向代理与反向代理attilax总结
  6. 8大排序算法图文讲解 分类: Brush Mode 2014-08-18 11:49 78人阅读 评论(0) 收藏
  7. jenkins忘记管理员账号密码的补救方法-转
  8. mysql学习--mysql必知必会1
  9. iOS之pch文件的正确使用
  10. CSS多行文字截断
  11. js 数字,金额 用逗号 隔开。数字格式化
  12. poj 2553 The Bottom of a Graph【强连通分量求汇点个数】
  13. TextView总结
  14. Replace不区分大小写
  15. Cola:一个分布式爬虫框架 - 系统架构 - Python4cn(news, jobs)
  16. [leetcode-593-Valid Square]
  17. Android-TextView 控件常用属性以及基本用法
  18. iptables防火墙规则的添加、删除、修改、保存
  19. Orleans学习总结(四)--集群配置篇
  20. Android -- Handling back button press Inside Fragments

热门文章

  1. Dubbo与Hadoop RPC的区别
  2. 为什么在 js在 function($) 前面加分号
  3. ELK-Filebeat使用
  4. django数据模型中关于on_delete的使用
  5. CVE-2012-2122-Mysql身份认证漏洞及利用
  6. UIView-frame-VS-bounds
  7. Determining the Size of a Class Object---sizeof(class)---By Girish Shetty
  8. Azure File挂载报错--System Error 1231
  9. P2319 [HNOI2006]超级英雄 题解
  10. Linx 的组管理和权限管理