0
I have no idea where is exactly the problem
#include "myClass.h" #include <iostream> using namespace std; myClass::deposit() { int sum1; cin>>sum1; balance += sum1; } myClass::withdraw() { int sum2; cin>>sum2; balance -= sum2; } myClass::getBalance() { return balance; } Then goes error alert: /Users/m_o**k/Documents/ClassTest/myClass.cpp|6|error: C++ requires a type specifier for all declarations|
3 Answers
+ 5
Donna
The balance variable has declared in the header file as part of the class interface. The problem lies in the missing return type of getBalance function definition.
int myClass::getBalance()
0
You have to make sure to include the return type for each of the functions. For example, getBalance() function returns a variable of type int, I assume. Therefore, the correct syntax is:
int myClass::getBalance(){return balance}
Do this for every function in your cpp file.