chapter8test7

来源:互联网 发布:手机淘宝在哪里做代理 编辑:程序博客网 时间:2024/04/28 11:17


#include<iostream>
using namespace std;
template<typename T>
T sum(T arr[], int n);
template<typename T>
T sum(T *arr[], int n);
struct debts
{
char name[20];
double amount;
};
int mian()
{
int things[6] = { 13, 25, 4, 10, 6, 98 };
debts mr[3] = {
{ "Ima Wolfe", 2400.0 },
{"Ura Foxe",1300.0},
{"Iby Stout",1800.0}
};
double *pd[3];
for (int i = 0; i < 3; i++)
pd[i] = &mr[i].amount;
cout << "Sum of Mr.'s countsof things: " << sum(things, 6) << endl;
double s = sum(pd, 3);
cout << "Sum of Mr.'s debts: " << s;
return 0;
}
template<typename T>
T sum(T arr[], int n)
{
T total=0;
for (int i = 0; i < n; i++)
total = arr[i];
return total;
}
template<typename T>
T sum(T *arr[], int n)
{
T total=0;
for (int i = 0; i < n; i++)
total += *(arr[i]);
return total;
}

这段程序在我的VS2013上边没有运行出来,错误提示如下,也不知道因问什么,求大神知道的告诉我
Error 1error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartupE:\tool software\VS2013_RTM_ULT_ENU\my wotk\chapter8job7\chapter8job7\MSVCRTD.lib(crtexe.obj)chapter8job7
Error 2 error LNK1120: 1 unresolved externals E:\tool software\VS2013_RTM_ULT_ENU\my wotk\chapter8job7\Debug\chapter8job7.exe1 1 chapter8job7
0 0
原创粉丝点击