Errors in program

Discussion in 'C++' started by Daz01, Nov 29, 2006.

  1. Daz01

    Daz01 Guest

    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
     
    Daz01, Nov 29, 2006
    #1
    1. Advertising

  2. Daz01

    rossum Guest

    On 29 Nov 2006 05:49:36 -0800, "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"; } }


    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
     
    rossum, Nov 29, 2006
    #2
    1. Advertising

  3. 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
     
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=, Nov 29, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    985
    Mark Goldin
    Jan 17, 2004
  2. SenthilVel
    Replies:
    0
    Views:
    961
    SenthilVel
    Jun 7, 2006
  3. George1776

    Out-of-memory errors and caching errors.

    George1776, Aug 28, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,315
    George1776
    Sep 14, 2006
  4. Lance Wynn
    Replies:
    1
    Views:
    1,874
    Lance Wynn
    Feb 3, 2008
  5. yawnmoth
    Replies:
    97
    Views:
    4,757
    Bent C Dalager
    Feb 27, 2009
Loading...

Share This Page