#include <iostream>
#include <string>
using namespace std;
template <typename T>
T SumArray(T arr[],int n);
template<typename T>
T SumArray(T* marr[],int n);
struct debts
{
char name[50];
double amount;
};
int main()
{
int things[6]={23, 43, 53,23,34,33};
struct debts mr[3]=
{
{"sffs",233.00},
{"dfaf",444.00},
{"fda",322.0}
};
double *pd[3];
for (int i=0;i<3;i++)
pd[i]=&mr[i].amount;
cout<<SumArray(things,6)<<endl;
cout<<SumArray(pd,3)<<endl;
system("pause");
return 0;
}
template <typename T>
T SumArray(T arr[],int n)
{
T total = 0;
for(int i = 0;i<n;i++)
{
total+=arr[i];
}
return total;
}
template <typename T>
T SumArray(T* arr[],int n)
{
T total = 0;
for(int i = 0;i<n;i++)
{
total+=*arr[i];
}
return total;
}
#include <string>
using namespace std;
template <typename T>
T SumArray(T arr[],int n);
template<typename T>
T SumArray(T* marr[],int n);
struct debts
{
char name[50];
double amount;
};
int main()
{
int things[6]={23, 43, 53,23,34,33};
struct debts mr[3]=
{
{"sffs",233.00},
{"dfaf",444.00},
{"fda",322.0}
};
double *pd[3];
for (int i=0;i<3;i++)
pd[i]=&mr[i].amount;
cout<<SumArray(things,6)<<endl;
cout<<SumArray(pd,3)<<endl;
system("pause");
return 0;
}
template <typename T>
T SumArray(T arr[],int n)
{
T total = 0;
for(int i = 0;i<n;i++)
{
total+=arr[i];
}
return total;
}
template <typename T>
T SumArray(T* arr[],int n)
{
T total = 0;
for(int i = 0;i<n;i++)
{
total+=*arr[i];
}
return total;
}