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

    dasjotre Guest

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


    #include <iostream>
    using std::cout;
     
    dasjotre, Nov 29, 2006
    #2
    1. Advertising

  3. Daz01

    Ron Natalie Guest

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

    #include <iostream>
    using std::cout;
    > void marina::OutputList (void) {


    the void in the parameter list is spurious.

    > // lists the entire list in the marina on the screen
    > boat * temp;



    > if (BoatName) {
    > for (temp=BoatName; temp; temp= temp->next) {


    Looks to me like you should investigate the std::list class.

    > cout << "\n" << temp->BoatName;
    > cout << " " << temp->BoatLen;
    > cout << " " << temp->BoatDep;
    > cout << " " << temp->BoatOwn; }}


    It would be helpful if you looked in Stroustrup or any of the
    other good C++ texts and format your code like they do. While
    it's largely a matter of taste, using one of the popular styles
    makes it easier for people to read your code. Newlines are
    cheap. Give the closing } it's own.

    > else {
    > //marina empty
    > cout << "\n\nMarina is empty"; } }
    >
    >
    > ERROR 2: expected init-declarator before "int" expected `,' or `;'
    > before "int"


    Most likely you are missing a semicolon or have mismatched a brace.
    If your editor/environment has an autoformatter or paren matcher...
    give that a shot to see if you can figure it out.
    >
    > int main()
    > {
    >
    > Any help would be great. I can post the entire program on here if that
    > helps. Thanks
    >
     
    Ron Natalie, Nov 30, 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:
    965
    Mark Goldin
    Jan 17, 2004
  2. SenthilVel
    Replies:
    0
    Views:
    947
    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,299
    George1776
    Sep 14, 2006
  4. Lance Wynn
    Replies:
    1
    Views:
    1,850
    Lance Wynn
    Feb 3, 2008
  5. yawnmoth
    Replies:
    97
    Views:
    4,727
    Bent C Dalager
    Feb 27, 2009
Loading...

Share This Page