Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Errors in program

Reply
Thread Tools

Errors in program

 
 
Daz01
Guest
Posts: n/a
 
      11-29-2006
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

 
Reply With Quote
 
 
 
 
rossum
Guest
Posts: n/a
 
      11-29-2006
On 29 Nov 2006 05:49:36 -0800, "Daz01" <(E-Mail Removed)> wrote:

>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
include either <ostream> or <iostream> as well if you have not already
done so.

>
>
>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

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


 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Erik_Wikstr=F6m?=
Guest
Posts: n/a
 
      11-29-2006
On 2006-11-29 14:49, Daz01 wrote:
> 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.

--

Erik Wikström
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net- 0 Build Errors, but I am prompted that there were build errors? Lance Wynn ASP .Net 1 02-03-2008 12:20 AM
Out-of-memory errors and caching errors. George1776 ASP .Net 2 09-14-2006 03:34 PM
Obsolete Errors and Deprecated Errors using Dotnet Framework 2.0 SenthilVel ASP .Net 0 06-07-2006 11:48 AM
Internet Explorer causing errors/ slow internet speed and Outlook express errors Jeanne Medley Computer Support 2 02-11-2004 11:44 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments