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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to convert from C to C++

Status
Not open for further replies.

idNut

Programmer
Aug 2, 2002
6
US
BankAccount::BankAccount()
{
cFname = (char*) malloc (sizeof(char) * ARY);
cLname = (char*) malloc (sizeof(char) * ARY);
iIDNumber = 0;
}

BankAccount::~BankAccount()
{
free(cFname);
free(cLname);
}

I haven't found out how to get new and delete to work for that right. cFname and cLname are both suppposed to be arrays of about 100. If I change anything I get 102 errors!
Help!
 
Assuming cFname and cLname are declared as char *, this should work:-

BankAccount::BankAccount()
{
cFname = new char[ARY];
cLname = new char[ARY];
iIDNumber = 0;
}

BankAccount::~BankAccount()
{
delete [] cFname;
delete [] cLname;
}

Regards,
Temps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top