Confusing Error Message

W

Wilson

Hi, while writing a simplified version of a program i created the
following class, however when i went to compile and run the program
there was an error saying

"multiple types in one declaration" and there was a mention of a
"[Build Error]" and "Error 1"

it also highlights the final line (the one with a closing brace and
semi-colon), i cannot see what is wrong with this, please help

wilson

class checking : public Account
{
friend void new_account();
public:
int abc;
};
 
M

Marcus Kwok

Wilson said:
Hi, while writing a simplified version of a program i created the
following class, however when i went to compile and run the program
there was an error saying

"multiple types in one declaration" and there was a mention of a
"[Build Error]" and "Error 1"

it also highlights the final line (the one with a closing brace and
semi-colon), i cannot see what is wrong with this, please help

wilson

class checking : public Account
{
friend void new_account();
public:
int abc;
};

You have not provided enough information to diagnose your problem. See
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
for guidelines on how to post code that doesn't work.
 
W

Wilson

Wilson said:
Hi, while writing a simplified version of a program i created the
following class, however when i went to compile and run the program
there was an error saying
"multiple types in one declaration" and there was a mention of a
"[Build Error]" and "Error 1"
it also highlights the final line (the one with a closing brace and
semi-colon), i cannot see what is wrong with this, please help

class checking : public Account
{
friend void new_account();
public:
int abc;
};

You have not provided enough information to diagnose your problem. Seehttp://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
for guidelines on how to post code that doesn't work.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply- Hide quoted text -

- Show quoted text -

sorry. the operating system is windows using Dev c++ and below is the
whole code, main() only includes a simple function call for one of the
classes which causes no problems. the full error message says "[Build
error] multiple types in one decleration "error 1" "

#include <iostream>
#include <time.h>
#include <fstream>
using namespace std;

class Account
{
public:
virtual void returnbalance(){ cout << balance; }
virtual void deposit(float amount)
{
balance += amount;
std::cout << "$" << amount << " Has Been Added To
Your Account" << std::endl;
}
virtual void withdraw(float amount)
{
if (balance > amount)
{
balance -= amount;
std::cout << "$" << amount << " Has Been
Withdrawn From Your Account" << std::endl;
}
else
{
std::cout << "Insufficient Funds" << std::endl;
}
}
protected:
float balance;
int pin_number;
int account_number;
}
///////////////////////////////////////////////////////
class checking : public Account
{
friend void new_account();
public:
int abc;
};
///////////////////////////////////////////////////////
class savings : public Account
{
friend void new_account();
public:
virtual void withdraw(float amount)
{
if (balance > amount && balance >= 200)
{
balance -= amount;
std::cout << "$" << amount << " Has Been
Withdrawn From Your Account";
if(amount >= 500)
{
balance = balance - 5;
std::cout << ", however a charge of $5
has been applied" << std::endl;
}
}
else
{
std::cout << "Insufficient Funds" << std::endl;
}
}
protected:
int numberofaccounts;
};
 
J

Jim Langston

Wilson said:
Wilson said:
Hi, while writing a simplified version of a program i created the
following class, however when i went to compile and run the program
there was an error saying
"multiple types in one declaration" and there was a mention of a
"[Build Error]" and "Error 1"
it also highlights the final line (the one with a closing brace and
semi-colon), i cannot see what is wrong with this, please help

class checking : public Account
{
friend void new_account();
public:
int abc;
};

You have not provided enough information to diagnose your problem.
Seehttp://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
for guidelines on how to post code that doesn't work.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply- Hide quoted text -

- Show quoted text -

sorry. the operating system is windows using Dev c++ and below is the
whole code, main() only includes a simple function call for one of the
classes which causes no problems. the full error message says "[Build
error] multiple types in one decleration "error 1" "

#include <iostream>
#include <time.h>
#include <fstream>
using namespace std;

class Account
{
public:
virtual void returnbalance(){ cout << balance; }
virtual void deposit(float amount)
{
balance += amount;
std::cout << "$" << amount << " Has Been Added To
Your Account" << std::endl;
}
virtual void withdraw(float amount)
{
if (balance > amount)
{
balance -= amount;
std::cout << "$" << amount << " Has Been
Withdrawn From Your Account" << std::endl;
}
else
{
std::cout << "Insufficient Funds" << std::endl;
}
}
protected:
float balance;
int pin_number;
int account_number;
}

Missing ; here. Should be
};
///////////////////////////////////////////////////////
class checking : public Account
{
friend void new_account();
public:
int abc;
};
///////////////////////////////////////////////////////
class savings : public Account
{
friend void new_account();
public:
virtual void withdraw(float amount)
{
if (balance > amount && balance >= 200)
{
balance -= amount;
std::cout << "$" << amount << " Has Been
Withdrawn From Your Account";
if(amount >= 500)
{
balance = balance - 5;
std::cout << ", however a charge of $5
has been applied" << std::endl;
}
}
else
{
std::cout << "Insufficient Funds" << std::endl;
}
}
protected:
int numberofaccounts;
};

Fix was in line. Scroll up, you were missing a ; after your definition of
class Account
 
K

Kenneth

Wilson said:
Hi, while writing a simplified version of a program i created the
following class, however when i went to compile and run the program
there was an error saying
"multiple types in one declaration" and there was a mention of a
"[Build Error]" and "Error 1"
it also highlights the final line (the one with a closing brace and
semi-colon), i cannot see what is wrong with this, please help
wilson
class checking : public Account
{
friend void new_account();
public:
int abc;
};
You have not provided enough information to diagnose your problem. Seehttp://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
for guidelines on how to post code that doesn't work.
- Show quoted text -

sorry. the operating system is windows using Dev c++ and below is the
whole code, main() only includes a simple function call for one of the
classes which causes no problems. the full error message says "[Build
error] multiple types in one decleration "error 1" "

#include <iostream>
#include <time.h>
#include <fstream>
using namespace std;

class Account
{
public:
virtual void returnbalance(){ cout << balance; }
virtual void deposit(float amount)
{
balance += amount;
std::cout << "$" << amount << " Has Been Added To
Your Account" << std::endl;
}
virtual void withdraw(float amount)
{
if (balance > amount)
{
balance -= amount;
std::cout << "$" << amount << " Has Been
Withdrawn From Your Account" << std::endl;
}
else
{
std::cout << "Insufficient Funds" << std::endl;
}
}
protected:
float balance;
int pin_number;
int account_number;}

///////////////////////////////////////////////////////
class checking : public Account
{
friend void new_account();
public:
int abc;};

///////////////////////////////////////////////////////
class savings : public Account
{
friend void new_account();
public:
virtual void withdraw(float amount)
{
if (balance > amount && balance >= 200)
{
balance -= amount;
std::cout << "$" << amount << " Has Been
Withdrawn From Your Account";
if(amount >= 500)
{
balance = balance - 5;
std::cout << ", however a charge of $5
has been applied" << std::endl;
}
}
else
{
std::cout << "Insufficient Funds" << std::endl;
}
}
protected:
int numberofaccounts;



};- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -

You're missing a semicolon at the end of one of your class
definitions. Classes definitions must have a semicolon after the
closing bracket.
 
M

Mike Wahler

Wilson said:
Hi, while writing a simplified version of a program i created the
following class, however when i went to compile and run the program
there was an error saying

"multiple types in one declaration" and there was a mention of a
"[Build Error]" and "Error 1"

it also highlights the final line (the one with a closing brace and
semi-colon), i cannot see what is wrong with this, please help

wilson

class checking : public Account
{
friend void new_account();
public:
int abc;
};

The error almost certainly is caused by something
in the portion of code you did not post.

-Mike
 
J

Jim Langston

Default User said:
ATM == Automatic Teller Machine machine.

You're the one who called it "ATM machine." I, and everyone I know, just
call it an ATM. As in, "Do you know where an ATM is?"

Incidently, I used to work for a company called ATM. Thought it would cool
working on ATMs. Turns out they made speaker racks for concerts :/
 
O

Old Wolf

You're the one who called it "ATM machine." I, and everyone I know, just
call it an ATM. As in, "Do you know where an ATM is?"

I wonder if their back end runs with Microsoft MTS Transaction Server
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top