Errors in program

D

Daz01

Hi all. Ive written a program and there are 2 errors that appear when I
try to compile the program. I dont know how to correct them. Any help
appreciated. Below are the errors

ERROR 1: `cout' undeclared (first use this function)

void marina::OutputList (void) {
// lists the entire list in the marina on the screen
boat * temp;
if (BoatName) {
for (temp=BoatName; temp; temp= temp->next) {
cout << "\n" << temp->BoatName;
cout << " " << temp->BoatLen;
cout << " " << temp->BoatDep;
cout << " " << temp->BoatOwn; }}
else {
//marina empty
cout << "\n\nMarina is empty"; } }


ERROR 2: expected init-declarator before "int" expected `,' or `;'
before "int"

int main()
{

Any help would be great. I can post the entire program on here if that
helps. Thanks
 
R

rossum

Hi all. Ive written a program and there are 2 errors that appear when I
try to compile the program. I dont know how to correct them. Any help
appreciated. Below are the errors

ERROR 1: `cout' undeclared (first use this function)

void marina::OutputList (void) {
// lists the entire list in the marina on the screen
boat * temp;
if (BoatName) {
for (temp=BoatName; temp; temp= temp->next) {
cout << "\n" << temp->BoatName;
cout << " " << temp->BoatLen;
cout << " " << temp->BoatDep;
cout << " " << temp->BoatOwn; }}
else {
//marina empty
cout << "\n\nMarina is empty"; } }

cout lives in the std namespace: use std::cout. You will have to
ERROR 2: expected init-declarator before "int" expected `,' or `;'
before "int"

int main()
{
You are probably missing a ';' on the line before your main() function
starts.

For very basic questions, alt.comp.lang.learn.c-c++ might be a better
bet.

rossum
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Hi all. Ive written a program and there are 2 errors that appear when I
try to compile the program. I dont know how to correct them. Any help
appreciated. Below are the errors

ERROR 1: `cout' undeclared (first use this function)

void marina::OutputList (void) {
// lists the entire list in the marina on the screen
boat * temp;
if (BoatName) {
for (temp=BoatName; temp; temp= temp->next) {
cout << "\n" << temp->BoatName;
cout << " " << temp->BoatLen;
cout << " " << temp->BoatDep;
cout << " " << temp->BoatOwn; }}
else {
//marina empty
cout << "\n\nMarina is empty"; } }


ERROR 2: expected init-declarator before "int" expected `,' or `;'
before "int"

Since I don't have the whole code I can't say for sure, but it sounds
like you have forgotten a ; before the main()-function (that's probably
where the 'int' comes from).

A tip: Try to put your '}' on their own lines, it was not apparent at
first that you had not forgotten one.
 

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,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top