1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#ifndef transaction_h
#define transaction_h
#include <string>
#include "List.h"
#include "Node.h"
#include "readfile.h"
using namespace std;
class transaction{
public:
int account,amount;
string date,time,type,location;
bool operator>= (transaction);
bool operator== (transaction);
};
void readTransaction(transaction&,List<transaction>*);
void insertTransaction();
void computeBalance();
bool transaction::operator>= (transaction t2) {
if (date.compare(t2.date) >= 0)
return true;
return false;
}
bool transaction::operator== (transaction t2) {
if (date.compare(t2.date) == 0)
return true;
return false;
}
#endif
|
Hi guys , after making this header and implementing it in other cpp files everything that uses this header went wrong , even before they doesn't . It generates a bunch of errors in other header files that include it . I'll give some of the file that includes it and the error here .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#ifndef readfile_h
#define readfile_h
#include <string>
#include "List.h"
#include "transaction.h"
using namespace std;
class customer
{
public:
string name,address,dob,phone,acc_type;
transaction t_input;//Every function that includes transaction.h points here and state has error .
List<transaction> trans;
double balance;
int account;
bool operator>=(customer);
bool operator==(customer);
};
void readFile(string,customer&,List<customer>*);
#endif
|
readfile.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include "insert_trans.h"
#include "List.h"
#include "transaction.h"
#include "readfile.h"
void insert_trans(List<customer> *list,List<transaction> *t_list)
{
customer input;
transaction t_input;
for(int i=0;i<t_list->size();i++)
{
list->get(i,input);
if(input.account==t_list->find(t_input)->item.account)
list->find(input)->item.trans(t_input);//when I hover my mouse over here it says List<<error type>> customer::trans .
}
}
|
This is insert_transaction function
These is the bunch of error generated
IntelliSense: identifier "transaction" is undefined
10 IntelliSense: identifier "transaction" is undefined
11 IntelliSense: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 6 error C2664: 'Node<T> *List<T>::find(int)' : cannot convert parameter 1 from 'customer' to 'int' 17 1 Assignment 2
Error 5 error C2512: 'customer' : no appropriate default constructor available 9 1 Assignment 2
Error 8 error C2228: left of '.trans' must have class/struct/union 17 1 Assignment 2
Error 7 error C2227: left of '->item' must point to class/struct/union/generic type
Error 1 error C2146: syntax error : missing ';' before identifier 't_input'
Error 4 error C2065: 'transaction' : undeclared identifier
I desperately need help , my tutor says this assignment should be easy but apparently it is not .