why is my functions not recognizing name and Bname.
main.cpp: In function ‘void setName(std::string)’:
main.cpp:38:5: error: ‘name’ was not declared in this scope
name=Bname;
^
main.cpp: In function ‘std::string getName()’:
main.cpp:42:8: error: ‘name’ was not declared in this scope
return name;
#include<iostream>
#include<string>
usingnamespace std;
class Bank_Account //name of the class
{
private:
string name; //attributes to the private so its protected
int acct_num;
int pin_num;
double Balance;
Bank_Account()
{
Balance=0; //balance needed to intialized
}
Bank_Account (double B)
{
Balance=B;
}
public:
void setName (); //for name to store
double getName (string); //for name to store and retrive name
void setAcctnum ();//account num to store
double getAcctnum (double); //acct num for retrive acct number
double getBalance (double);//retrieve the balance
bool setPIN (double); // to store number
double checkPIN(double); // receives a PIN number as parameter, returns TRUE if it matches the PIN in the object
void deposit(); // Receives amount of money to deposit.If this amount is valid (positive) then + to balance. Otherwise do nothing. No return value.
void withdraw(); // Receives amount of money to withdraw. If this amount is valid(positive) then make sure there are funds to cover the withdrawl.
//If so then subtract from balance. If not enough money then printthe message “Insufficent funds” and make no changes. No return value
};
void setName (string Bname)
{
name=Bname;
}
string getName ()
{
return name;
}
int main()
{
}
For the compiler it looks like a normal, free function.
No way of knowing it that it belongs Bank_Account class as I can guess.
You need to add Bank_Account:: in front of the function name.