Reputation: 7078
I have searched quite thoroughly on this but can't seem to find an answer.
I have a "bank" class that naturally has a vector. here is one of the functions with the problematic part:
int bank::open(op *o, int id)
{
account *acc = new account();
if (search(o->account))
return ACCOUNT_EXISTS;
accounts.push_back(acc->open(o, id));
}
and i get a "syntax error : identifier 'account' and "'acc' : undeclared identifier error.
this .cpp has
#include "bank.h"
which has #include "bank_account.h"
(which is the banks personal account) which has #include "account.h"
, and there is absolutely no way for a circular reference.
if I type account::
the scope is visible, and if I right click and search for the declaration it (VS 2008) finds it.
here is the account.h
class declaration
class account
{
public:
account(void) {}
~account(void) {}
int number;
int password;
int bal;
//void openAccount(op *o, int id);
void deposit(int amount, int id);
int withdraw(int amount, int id);
void balance(int id);
void close(int id);
int comission(float percentage);
void log(int msg, int id, int amount=0);
};
Thanks for any help...
Upvotes: 0
Views: 1193
Reputation: 114
Is it possible that some of your headers have the same header guards? It looks like you think a header should be included but it isn't.
So make sure that you don't have
#if !defined( BANK_H )
#define BANK_H
#endif //BANK_H
Or something similar in multiple files. Each header file should have guards, but not the same ones :)
Upvotes: 0
Reputation: 64730
First, on this line:
accounts.push_back(acc->open(o, id));
You are calling acc->open()
, and acc
is of type account*
.
But I do not see any definition for method open
in class account
.
Therefore, you cannot call the open
via the acc
pointer.
The closest match is the method openAccount
, but that is currently commented out, and cannot be used.
accounts.push_back()
.bank
does not have a member accounts
.Upvotes: 1
Reputation: 6582
try to include account.h
in the cpp file in questions. It's better to include what you use and not to rely on other include files to include things for you.
It seems that you are leaking account
objects. They are never freed (regardless if the account exists or not)
Could it be that the account
class is in a different namespace?
Upvotes: 0