I had written this function [ total_tax() ] which takes an array of objects of type tax and does some calculations on the private members of objects of tax.
Code:
void total_tax (const tax *Tax)
{
float Total = 0, Tax_Value;
for (int i=0;i<300;i++)
Total += *(Tax + i)->charge ;
Tax_Value = .4 * Total;
cout <<"\n The total tax to be paid is "<<Tax_Value;
}
The friend function declaration in class tax is as follows
Code:
class tax
{
public:
tax();
tax(float);
virtual ~tax();
friend void total_tax (const tax*);
private:
float charge;
The main() is as follows..
Code:
void main()
{
int i = 0;
tax *Array[];
for (i=0;i<100;i++)
Array[i] = new tax (3000);
for (i=100;i<300;i++)
Array[i] = new tax (5000);
total_tax (Array);
}
This however doesn't compile. I get errors like
syntax error : missing ',' before '*'
left of '->charge' must point to class/struct/union
Please help.....my OOP test is on Saturday ....