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|

9th Jun 2018, 6:46 PM
DaMagus
DaMagus - avatar
3 Respostas
+ 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()
9th Jun 2018, 8:03 PM
Babak
Babak - avatar
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.
2nd Jul 2018, 9:51 PM
Louie
Louie  - avatar