I had this working completely fine earlier and now ever since I reopened my project it doesnt compile anymore and I have no idea why. I'm using Netbeans and have tried reparsing the project several times.
main (Yes header file is included)
1 2 3 4 5 6 7
int main (){
cout << boolalpha << setprecision(2) << fixed;
double query;
bool result;
Bank bnk("Bank of Evil");
cout << "Bank Name:"<<bnk.bank_name()<<endl;
cout << "Bank ID:"<<bnk.bank_id()<<endl;
Bank::Bank(string name){ //Constructor for the bank, takes in a string for the bank name.
name_ = name;
bank_id_ = random_ID();
}
string Bank::bank_name() //Allows the banks name to be printed
{
returnthis->name_;
}
long Bank::random_ID() //Generates the bank's ID number
{
long random;
long lower = 10000;
long upper = 99999;
random = rand() % upper + lower;
return random;
}
long Bank:: bank_id() //Allows the bank ID to be printed
{
returnthis->bank_id_;
}
bank.h
1 2 3 4 5 6 7 8 9 10
class Bank{
string name_;
long bank_id_;
Bank (string);
friend string bank_name();
friendlong random_ID();
friendlong bank_id();
};
Errors
1 2 3 4 5 6
proj09-bank.h: In function ‘int main()’:
In file included from main.cpp:20:0:
proj09-bank.h:32:4: error: ‘Bank::Bank(std::string)’ is private
main.cpp:26:26: error: within this context
main.cpp:27:29: error: ‘class Bank’ has no member named ‘bank_name’
main.cpp:28:27: error: ‘class Bank’ has no member named ‘bank_id’