can someone help me with error codes please.
main.cpp: In function ‘int main()’:
main.cpp:13:5: error: ‘Bank_Account::Bank_Account()’ is private
Bank_Account()
^
main.cpp:48:18: error: within this context
Bank_Account ob;
^
main.cpp:51:26: error: expected primary-expression before ‘)’ token
cin>>ob.setName(string);
^
#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 (string); //for name to store
string getName (); //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 Bank_Account::setName (string Bname)
{
name=Bname;
}
string Bank_Account::getName ()
{
return name;
}
int main()
{
Bank_Account ob;
cout<<"what is name";
cin>>ob.setName(string);
return 0;
}
.
int main()
{
Bank_Account ob; // Error: you cannot create account, because the constructor is not public
cout<<"what is name";
cin>>ob.setName(string); // Error: What is a "string"? Error: cin >> void
return 0;
}
Perhaps you should make the constructors public?
Read to string variable first. Then call setName() with that variable.
As keskiverto hinted at, setName returns void (that is, it returns nothing), so you can't use it directly with cin >>.
That's not how you'd call a function anyway, I highly suggest reading http://www.cplusplus.com/doc/tutorial/functions/