So far I have this as my main
#include <string>
#include <iostream>
# include <fstream>
#include "money.h"
using namespace std;
int main ()
{
ifstream infile;
ifstream outfile;
infile.open ("transaction.dat");
int precision = 6;
int width = 20;
if (infile.fail ())
{
cout << "Opening input failed" << endl;
}
int holds, holdd, holdw, holdc;
for (int i=0; i<100; i++)
{
long dollars;
int cents;
char account_type, transaction_type;
infile >> dollars >> cents >> account_type >> transaction_type;
//if test(account_type == s ||account_type == c)
char withdraw [100];
char deposit [100];
if (transaction_type == 'w')
{
withdraw [100] = 'w';
}
else
{
deposit [100] = 'd';
}
}
return 0;
}
and my inplementation of my .h file is...
//Author: Aaron Reisinger
//Name: Money.cpp
//Description: Adds and stores two amounts and outputs the sum.
//Date:3/23/2010
#include "money.h"
money money:: add (money m1, money m2)
{
money sum (0,0);
sum.all_cents = m1.all_cents + m2.all_cents;
return sum;
}
money:: money ()
{
dollars = cents = all_cents=0;
}
money:: money (long d, int c)
{
dollars = d;
cents = c;
all_cents = d * 100 + c;
}
double money:: get_value()
{
return all_cents;
}
void money:: collect_data()
{
cout << "How many dollars do you have?: ";
cin >> dollars;
cout << "How many cents do you have?: ";
cin >> cents;
all_cents = dollars * 100 + cents;
}
void money:: output ()
{
cout << "$ " << all_cents << endl;
}
and my .h file is...
#include <iostream>
using namespace std;
class money
{
public:
money ();
//default empty constructor.
//initialize all private data properly.
money (long d, int c);
//constructor assigning private data.
money (long d, int c, char type, char transaction);
//constructor assigning private data.
money (long all_cents);
//assign dollars, cents and all_cents.
money add (money m1, money m2);
//add the total amount of each money and return a new object containing this value.
void output ();
//show amounts of this object.
void collect_data ();
//collect dollars and cents and assign all_cents.
long set_value ();
//return the value of all_cents.
double get_value ();
private:
char at; //account type
char trans; //transaction type
long dollars;
int cents;
double all_cents;
};
what can I do?