<pre name="code" class="cpp">#include<iostream>
#include<fstream>
#include<cstdlib>//
#include<string>
#include<cctype>
using namespace std;
struct debts
{
char name[50];
double amount;
};
template<typename T>
void ShowArray(T arr[],int n);
template<typename T>
void ShowArray(T *arr[],int n);
template<typename T>
void ShowArray(T arr[],int n)
{
cout<<"template A\n";
for(int i =0;i<n;i++)
cout<<arr[i]<<' ';
cout<<endl;
}
template<typename T>
void ShowArray(T * arr[],int n)
{
cout<<"template B\n";
for(int i=0;i<n;i++)
cout<<*(arr[i])<<' ';
cout<<endl;
}
void main()
{
int things[6]={13,31,103,301,310,130};
struct debts mr_E[3]=
{
{"Ima Wolfe",2400.00},
{"Ura Foxe",1300.0},
{"Iby Stout",1800.0}
};
double * pd[3];
for(int i=0;i<3;i++)
pd[i] = &mr_E[i].amount;
cout<<"Listing Mr.E's counts od thinfs:\n";
ShowArray(things,6);
cout<<"Listing Mr.E's debts:\n";
// ShowArray(pd,3);//VC++6.0不支持重载解析,所以这句无法通过编译
}
C++primer plus第六版课后编程练习答案8.7
最新推荐文章于 2020-04-23 09:50:33 发布