CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2011
    Posts
    4

    ISO C++ forbids declaration of..

    Hi, i'm doing an application with Qt/OpenGL and i have some problems with auxiliar functions to open files in Qt.

    I receive these errors:

    ISO C++ forbids declaration of "open" with no type
    ISO C++ forbids declaration of "loadFile" with no type

  2. #2
    Join Date
    Apr 2011
    Posts
    4

    Re: ISO C++ forbids declaration of..

    Sorry, error typing, i've not finished the text already ^^

    You can see here the code of each function:

    MenuPrincipal:pen()
    {
    QString fileName = QFileDialog::getOpenFileName(this);
    if (!fileName.isEmpty())
    loadFile(fileName);
    return 0;
    }

    MenuPrincipal::loadFile(const QString &fileName)
    {
    QFile file(fileName);
    if (!file.open(QFile::ReadOnly | QFile::Text)) {
    QMessageBox::warning(this, tr("Application"),
    tr("Cannot read file %1:\n%2.")
    .arg(fileName)
    .arg(file.errorString()));
    return 0;
    }

    QApplication::setOverrideCursor(Qt::WaitCursor);
    QApplication::restoreOverrideCursor();

    setCurrentFile(fileName);
    return 0;

    }

    and the code in the header:

    private slots:
    int open();
    private:
    int loadFile(const QString &fileName);

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: ISO C++ forbids declaration of..

    [ Moved thread ]

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: ISO C++ forbids declaration of..

    Just add the int that you have in your header file declarations to the function header introducing the function implementation as well. That's the simple truth this error message is telling you.

    Please use code tags when posting code.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: ISO C++ forbids declaration of..

    Seriously, you can't put this
    ISO C++ forbids declaration of "loadFile" with no type

    and this
    MenuPrincipal::loadFile(const QString &fileName)

    together and figure out what you did wrong?

Tags for this Thread

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