CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2009
    Posts
    34

    expected constructor, destructor...

    Greetings.

    I'm getting the following error while using Netbeans 6.9.1 on C++ code.

    ../GNU_iomanip.h:27: error: expected constructor, destructor, or type conversion before '&' token
    ../GNU_iomanip.h:27: error: expected `,' or `;' before '&' token



    This is the code:

    //------------------------------------------------------------------------------
    //
    // GNU_iomanip.h
    //
    // Purpose:
    //
    // Temporaray implementation of ostream manipulators from the
    // C++ Standard Library, which are not contained in <iomanip>
    // as provided with GNU C++.
    //
    // Notes:
    //
    // This software is protected by national and international copyright.
    // Any unauthorized use, reproduction or modificaton is unlawful and
    // will be prosecuted. Commercial and non-private application of the
    // software in any form is strictly prohibited unless otherwise granted
    // by the authors.
    //
    // (c) 1999 Oliver Montenbruck, Thomas Pfleger
    //
    //------------------------------------------------------------------------------

    #include <iomanip>
    #include <iostream>

    namespace{

    ostream& left(ostream& os)
    {
    os.setf(ios::left ,ios::adjustfield);
    return os;
    };

    ostream& right(ostream& os){os.setf(ios::right,ios::adjustfield); return os;};
    ostream& fixed(ostream& os){os.setf(ios::fixed,ios::floatfield); return os;};
    ostream& showpos (ostream& os){os.setf(ios::showpos); return os;};
    ostream& noshowpos(ostream& os){os.unsetf(ios::showpos); return os;};

    }


    I don't know what it is trying to tell me.

    Any help?

    Thanks.
    Webbiz

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

    Re: expected constructor, destructor...

    All the objects etc. are located in namespace std. Example:

    Code:
    std::ostream& left(std::ostream& os)
    {
    	os.setf(std::ios::left ,std::ios::adjustfield);
    	return os;
    };
    The date on that code is 1999 ... Are you sure g++ still does not have them ?

  3. #3
    Join Date
    May 2009
    Posts
    34

    Re: expected constructor, destructor...

    I'm not sure how to answer your question.

    All I know is that unless I add the std:: that you just showed me, it will give me those errors.

    You seem to know what this issue is. I'm a newbie, so I'm a bit confused at this point.

    BTW, this is on a Windows 7 system and not Linux. Using Cygwin with Netbeans.

    Is there a setup parameter or something that I'm missing?

    Thanks.

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: expected constructor, destructor...

    Quote Originally Posted by webbiz View Post
    I'm not sure how to answer your question.

    All I know is that unless I add the std:: that you just showed me, it will give me those errors.

    You seem to know what this issue is. I'm a newbie, so I'm a bit confused at this point.

    BTW, this is on a Windows 7 system and not Linux. Using Cygwin with Netbeans.
    What version of gcc is being used (gcc is the actual compiler being used, not Netbeans, which is an IDE).

    Second, that code dates back to 1999. This means there is a good chance that this code no longer is valid ANSI C++ code. That's why it's necessary to add std::, since those stream classes are in the std:: namespace.

    Regards,

    Paul McKenzie

  5. #5
    Join Date
    May 2009
    Posts
    34

    Re: expected constructor, destructor...

    This is a new installation. I downloaded the latest cygwin. Not sure how to tell what the version of gcc is. Looking at the properties doesn't seem to help.

    Isn't the ANSI C++ standard dated 1998?


    Webbiz

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: expected constructor, destructor...

    Quote Originally Posted by webbiz View Post
    This is a new installation. I downloaded the latest cygwin. Not sure how to tell what the version of gcc is. Looking at the properties doesn't seem to help.
    Go to the command line and start the compiler (gcc.exe). I don't know the exact command-line to give you the version, but it is available.
    Isn't the ANSI C++ standard dated 1998?
    Yes, but many compilers still did not adhere to the standard fully at that point. I could understand if the year were 2000 or later, but 1999 puts it too close to 1998.

    Regards,

    Paul McKenzie

  7. #7
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: expected constructor, destructor...

    -v gives you the version

  8. #8
    Join Date
    May 2009
    Posts
    34

    Re: expected constructor, destructor...

    Unfortunately running gcc -v only gives me an error.

    The NTVDM CPU has encountered an illegal instruction.

    This is Windows 7. I had to give myself permission just to run it to this point. Yet, Netbeans doesn't seem to have any problem using it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured