<function> is not a member of <class>

Swanav picture Swanav · Sep 5, 2014 · Viewed 26.1k times · Source

I have declared my function 'Credit' as a private member with some arguments. My observation is that whenever I try to compile without any argument the compiler will compile successfully. but as soon as I compile with the arguments in the function, the compiler gives an error

'Transaction :: Credit' is not a member of 'Transaction'

Here is my code

class Transaction : public Menu
{
private :

    void Credit(int depost);//{ return 0;}

public :
    void Deposit();
    void Withdraw(){}
    void Transfer(){}
};

void Transaction :: Deposit()
{
       char custid[10]; int deposit;

       clrscr();
       cout << endl << endl << endl << endl << endl;
       cout << "\t\t\t\t  DEPOSIT " << endl;
       cout << "\t\t   Please enter your Customer ID" << endl;
       cin  >> custid;
       cout << "\t\t   Please enter the amount you want to deposit (in Rupees)" << endl;
       cin  >> deposit;

 //      Credit (depost);
}

void Transaction :: Credit (depost)
{

}

I am using Turbo C++, so please guide me according this IDE.

Answer

RockOnRockOut picture RockOnRockOut · Sep 5, 2014

You're missing the type of depost:

void Transaction :: Credit (int depost)

And it is considered bad practice to start the name of functions with a capital letter. The names of classes should start with capital letters. Functions and variables should have names that start with lowercase letters.