I am trying to make an ATM machine, while trying to teach myself how classes interact with each other. I feel as though the main idea of the program is correct, but as you can see, I am having a lot of syntax errors.

If you guys see something that I am doing wrong (evidently there are several), can you please point them out. Thanks ahead of time guys :).

Here are my errors:

source1.cpp(28) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
source1.cpp(39) : warning C4183: 'Credit': missing return type; assumed to be a member function returning 'int'
source1.cpp(41) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
source1.cpp(52) : warning C4183: 'Debit': missing return type; assumed to be a member function returning 'int'
source1.cpp(59) : error C2236: unexpected 'class' 'SavingsAccount'. Did you forget a ';'?
source1.cpp(59) : error C2143: syntax error : missing ';' before ':'
source1.cpp(13) : error C2059: syntax error : ':'
source1.cpp(59) : error C2059: syntax error : 'public'
source1.cpp(60) : error C2143: syntax error : missing ';' before '{'
source1.cpp(60) : error C2447: '{' : missing function header (old-style formal list?)
source1.cpp(100) : error C2628: 'CheckingAccount' followed by 'int' is illegal (did you forget a ';'?)
source1.cpp(101) : error C3874: return type of 'main' should be 'int' instead of 'CheckingAccount'
source1.cpp(103) : error C2065: 'SavingsAccount' : undeclared identifier
source1.cpp(103) : error C2146: syntax error : missing ';' before identifier 'S1'
source1.cpp(103) : error C3861: 'S1': identifier not found
source1.cpp(117) : error C2228: left of '.Newbalance' must have class/struct/union
1> type is ''unknown-type''
source1.cpp(82) : error C2512: 'Account' : no appropriate default constructor available

#include <iostream>
using namespace std;

class Account
{
private:
	
protected:
	double balance;
	double n;
	double s;
public:
	Account(double balance)
	{
		cout << "Please enter your starting balance" << endl;
		cin >> balance;
		if (balance<0.00)
		{
			cout << "Insufficient funds.... you have $0.00" << endl;
			balance = 0.00;
		}
		else
		{
			cout << "Your account has been created" << endl;
		}
	}
	Credit(double n)
	{
		cout << "How much money would you like to add?" << endl;
		cin >> n;
		if (n>0.00)
		{
			balance = n + balance;
		}
		else
		{
			cout << "That is not a correct amount to add" << endl;
		}
	}
	Debit(double s)
	{
		cout << "How much would you like to remove?" << endl;
		cin >> s;
		if(s>balance)
		{
			cout << "You are attempting to overdraw" << endl;
		}
		else
		{
			balance = balance - s;
		}
	}
	void DisplayAccount()
	{
		cout<< "Your current balance is" << balance << endl;
	}
}

class SavingsAccount : public Account
{
protected:
	double interest;
public:
	SavingsAccount(double interest)
	{
		cout<<"Please enter the interest rate" << endl;
		cin >> interest;
	}
	void Newbalance()
	{
		balance = interest * balance;
	}
}

class CheckingAccount : public Account
{
protected:
	double m;
	double n;
public:
	CheckingAccount(double m)
	{
		cout << "How much would you like to remove?" << endl;
		cin >> m;
		if(m>balance)
		{
			cout << "You are attempting to overdraw" << endl;
		}
		else
		{
			n= 2.25;
			m= m*n;
			balance = balance - m;
		}
	}
}


int main()
{
	CheckingAccount C1(100.0);
	SavingsAccount S1(300.0);
	Account * ac;
	ac = &C1;
	ac->Credit(50.0);
	ac->Debit(10.0);
	ac->DisplayAccount();
	ac->Debit(200.00);
	ac->DisplayAccount();


	ac = &S1;
	ac->Credit(150.10);
	ac->Debit(20.0);
	ac->DisplayAccount();
	S1.Newbalance();
	ac->DisplayAccount();
	return 0;

}

You could try just reading your error messages carefully and figuring out what they mean.

For example.
warning C4183: 'Credit': missing return type; assumed to be a member function returning 'int'

[B]/*What goes here?*/[/B] Credit(double n)
	{
		cout << "How much money would you like to add?" << endl;
		cin >> n;
		if (n>0.00)
		{
			balance = n + balance;
		}
		else
		{
			cout << "That is not a correct amount to add" << endl;
		}
	}

Is it really so hard to figure out what you should make the function return?

Work through the messages one at a time, and see what you can come up with.

In future, press "compile" every time you add an empty class, and every time you add a new function to the class (or file). Then you won't be swamped with errors caused by many hours of sloppy coding, and you can nip any "copy/paste" errors before they have a chance to replicate.

If you're going to be a jackass go ahead and refrain from using your keyboard, no one wants to read your insolence. He asked for help, not destructive criticism.

Regardless, I have to agree that a fair amount of the time if you read the compiler message, you will generally be able to decipher what is actually wrong with your code.

I am actually programming essentially the exact same application right now for a test and I share one of your errors, but I have no idea how to fix it.

One thing I do suggest though is to separate your class definitions and driver files. When you are debugging it helps tremendously in locating exactly where something is going wrong.

commented: Here's another tip - read the post dates before opening your yapper -4

If you're going to be a jackass go ahead and refrain from using your keyboard, no one wants to read your insolence. He asked for help, not destructive criticism.

Regardless, I have to agree that a fair amount of the time if you read the compiler message, you will generally be able to decipher what is actually wrong with your code.

I am actually programming essentially the exact same application right now for a test and I share one of your errors, but I have no idea how to fix it.

One thing I do suggest though is to separate your class definitions and driver files. When you are debugging it helps tremendously in locating exactly where something is going wrong.

the criticism seemed constructive IMO, the error was blatantly obvious

If you're going to be a jackass go ahead and refrain from using your keyboard, no one wants to read your insolence. He asked for help, not destructive criticism.

Regardless, I have to agree that a fair amount of the time if you read the compiler message, you will generally be able to decipher what is actually wrong with your code.

I am actually programming essentially the exact same application right now for a test and I share one of your errors, but I have no idea how to fix it.

One thing I do suggest though is to separate your class definitions and driver files. When you are debugging it helps tremendously in locating exactly where something is going wrong.

He wasn't being a jackass. Most of his errors are syntax errors and the compiler is more than enough to give a clue what is wrong and even specifies the line number. This shows the poster the lack of care, that he rather posts his whole code and errors so that we can figure it out while it does take a few minutes to read the error and find out.

Such error as not including a return type in a function is just ridiculous. If you are having syntax trouble and have not yet master the basics of return type then the poster should not be messing with classes and inheritance.

Here is the ATMx1000.cpp file which calls the ATM.x1000.h file

//Automatic Teller Machine
#include <iostream>
#include <cmath>
using namespace std;
#include "ATMx1000.h"

void main ()
{
    ACCOUNT x;
    
    double balance;
    double interest;
    double m;
    double n;
    double s;
    
    
    x.Account();
    /////////////////////////////////////////////////////////////////
    
    x.Credit();
    /////////////////////////////////////////////////////////////////
    
    x.Debit();
    /////////////////////////////////////////////////////////////////
    
    x.DisplayAccount();
    /////////////////////////////////////////////////////////////////
    
    x.SavingsAccount();
    /////////////////////////////////////////////////////////////////
    
    x.Newbalance();
    /////////////////////////////////////////////////////////////////
    
    x.CheckingAccount();
    /////////////////////////////////////////////////////////////////
}

And here is the header file.

//code was taken from http://www.daniweb.com/forums/thread95001.html
//the code had ALOT of errors...i have tweeked and redone the code to try
//and make it work correctly.

#include <iostream>
#include <cmath>
using namespace std;

class ACCOUNT
{
private:

double interest;
double balance;
double newbalance;
double m;
double n;
double s;

public:
void Account()
{
cout << "Please enter your starting balance. $" << endl;
cin >> balance;

if (balance<0.00)
{
cout << "Insufficient funds.... you have $0.00!" << endl;
balance = 0.00;
}
else
{
cout << "Your account has been created!" << endl;
}
}

void Credit()
{
cout << "\nHow much money would you like to add? $" << endl;
cin >> n;

if (n>0.00)
{
balance = n + balance;
}
else
{
cout << "That is not a correct amount to add!" << endl;
}
}

void Debit()
{
cout << "How much money would you like to remove? $" << endl;
cin >> s;

if(s > balance)
{
cout << "You are attempting to overdraw!" << endl;
}
else
{
balance = balance - s;
}
}

void DisplayAccount()
{
cout<< "Your current balance is $" << balance << endl;
}

void SavingsAccount()
{
cout<<"Please enter the interest rate. " << endl;
cin >> interest;
}

void Newbalance()
{

newbalance = (interest * balance) + balance;
cout << "your new balance is $"<<newbalance<<endl;
}

void CheckingAccount()
{
cout << "How much would you like to remove? $" << endl;
cin >> m;

if(m>newbalance)
{
cout << "You are attempting to overdraw!" << endl;
}
else
{
cout<<"There will be a $2.25 service charge."<<endl;
n= 2.25;
balance = newbalance - (m+n);
cout<<"your new balance is $"<<balance<<endl;
}
}
};

Sorry bout that...here is the header file easier to read.

//code was taken from http://www.daniweb.com/forums/thread95001.html
//the code had ALOT of errors...i have tweeked and redone the code to try
//and make it work correctly.

#include <iostream>
#include <cmath>
using namespace std;

class ACCOUNT
{
private:

double interest;
double balance;
double newbalance;
double m;
double n;
double s;

public:
void Account()
{
cout << "Please enter your starting balance. $" << endl;
cin >> balance;

if (balance<0.00)
{
cout << "Insufficient funds.... you have $0.00!" << endl;
balance = 0.00;
}
else
{
cout << "Your account has been created!" << endl;
}
}

void Credit()
{
cout << "\nHow much money would you like to add? $" << endl;
cin >> n;

if (n>0.00)
{
balance = n + balance;
}
else
{
cout << "That is not a correct amount to add!" << endl;
}
}

void Debit()
{
cout << "How much money would you like to remove? $" << endl;
cin >> s;

if(s > balance)
{
cout << "You are attempting to overdraw!" << endl;
}
else
{
balance = balance - s;
}
}

void DisplayAccount()
{
cout<< "Your current balance is $" << balance << endl;
}

void SavingsAccount()
{
cout<<"Please enter the interest rate. " << endl;
cin >> interest;
}

void Newbalance()
{

newbalance = (interest * balance) + balance;
cout << "your new balance is $"<<newbalance<<endl;
}

void CheckingAccount()
{
cout << "How much would you like to remove? $" << endl;
cin >> m;

if(m>newbalance)
{
cout << "You are attempting to overdraw!" << endl;
}
else
{
cout<<"There will be a $2.25 service charge."<<endl;
n= 2.25;
balance = newbalance - (m+n);
cout<<"your new balance is $"<<balance<<endl;
}
}
};

It took me about 6 days to figure out everything and I am using the Borland Compiler (kinda crappy) but what ever works here in school. Hope this helps. A lot of your problem was that you were doing a lot of data shadowing. Just try to go through each member function, debug it (give it a "cout" to make sure everything works", and then move on. Again hope it helps!

NCTKID1, what is the purpose of your three posts on this thread? To me they don't seem like they would help anyone, considering all you are doing is post some code that is a complete alternative to the original posters code. And even if it did help him, did you consider that this thread was started more than 3 years ago?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.