C
Chun Wah
I am new to C++ and trying to write a accounting application class. This
"account" class is derived from base "books" which has 4 data. I got a
compile error as follow and not sure what goes wrong.
75: error: ISO C++ forbids defining types
within return type
75: error: return type specification for
constructor invalid
line 75 is in the constructor.
Another question is: is there a return type of a constructor ? isnt it
the object itself ?
class account
{
private:
std::string acname;
int level;
bool generaldetail; //0-general, 1-detail
int type; //1-asset, 2-liability, 3-capital, 4-income, 5-expense
float balance;
bool recorded;
public:
account (const std::string& nn, int lvl, bool gd, int t,
float bal, bool rec);
std::string getname(void);
int getlevel(void);
bool getgeneraldetail(void);
int gettype(void);
float getbalance(void);
bool getrecorded(void);
}
// constructor
account::account (const std::string& nn, int lvl, bool gd, int t,
float bal, bool rec): // line 75
acname(nn),
level(lvl),
generaldetail(gd),
type(t),
balance(bal),
recorded(rec)
{}
"account" class is derived from base "books" which has 4 data. I got a
compile error as follow and not sure what goes wrong.
75: error: ISO C++ forbids defining types
within return type
75: error: return type specification for
constructor invalid
line 75 is in the constructor.
Another question is: is there a return type of a constructor ? isnt it
the object itself ?
class account
{
private:
std::string acname;
int level;
bool generaldetail; //0-general, 1-detail
int type; //1-asset, 2-liability, 3-capital, 4-income, 5-expense
float balance;
bool recorded;
public:
account (const std::string& nn, int lvl, bool gd, int t,
float bal, bool rec);
std::string getname(void);
int getlevel(void);
bool getgeneraldetail(void);
int gettype(void);
float getbalance(void);
bool getrecorded(void);
}
// constructor
account::account (const std::string& nn, int lvl, bool gd, int t,
float bal, bool rec): // line 75
acname(nn),
level(lvl),
generaldetail(gd),
type(t),
balance(bal),
recorded(rec)
{}