Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on defining a class type for a bank account.

Status
Not open for further replies.
Mar 13, 2001
1
US
I am writing a program in which I need to define a class type for a bank account and I wanted to check for syntax errors as I went. The problem is I am getting errors for reasons I cannot understand. What I have below is supposed to be the first few lines which should work if there are no syntax errors. Here is what I have. I am using MS Visual C++ 6.0

#include <iostream.h>
#include &quot;tstring.h&quot;

class BankAccount
private:
double balance;
String accountID;
{

};

void main()
{

}

Here are the errors that I get whe I compile.

--------------------Configuration: testxx - Win32 Debug--------------------
Compiling...
testxx.cpp
C:\testxx.cpp(5) : error C2143: syntax error : missing ';' before 'private'
C:\testxx.cpp(5) : error C2143: syntax error : missing ';' before 'private'
C:\testxx.cpp(8) : error C2447: missing function header (old-style formal
list?)
Error executing cl.exe.

testxx.obj - 3 error(s), 0 warning

 
It should be like this:

#include <string.h>
class BankAccount
{
private:
double balance;
String accountID;


};
Best Regards,

aphrodita@mail.krovatka.ru {uiuc rules}
 
you'll have better luck doing this

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

class BankAccount
{
private:
double balance;
string accountID;
};

----------------
remember anytime you #include
its a good idea to also write
using namspace std;
and don't use <string.h>
it limmits you
thats the old style use the new
<string> it is more powerful
good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top