Compiler Error

Discussion in 'C++' started by elShazo@gmail.com, Apr 22, 2007.

  1. Guest

    I am getting this error on compile "expected unqualified-id at end of
    input".

    Here is the block of code that generates the error:

    /* Proxy unmountSource I/O */
    /* Method unmountSource */
    void unmountSource(string theSource)
    {
    string source = theSource;
    string unmount = "unmount ";
    string unmountFull = unmount + source;
    string rmdir = "rmdir ";
    string rmdirFull = rmdir + source;
    system(unmountFull.c_str());
    system(rmdirFull.c_str());
    }
    /* EMethod */
    /* EProxy */

    Compiler points to the line that has the end curly brace. Any ideas or
    at least what the error means?
     
    , Apr 22, 2007
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > I am getting this error on compile "expected unqualified-id at end of
    > input".
    >
    > Here is the block of code that generates the error:
    >
    > /* Proxy unmountSource I/O */
    > /* Method unmountSource */
    > void unmountSource(string theSource)
    > {
    > string source = theSource;
    > string unmount = "unmount ";
    > string unmountFull = unmount + source;
    > string rmdir = "rmdir ";
    > string rmdirFull = rmdir + source;
    > system(unmountFull.c_str());
    > system(rmdirFull.c_str());
    > }
    > /* EMethod */
    > /* EProxy */
    >
    > Compiler points to the line that has the end curly brace. Any ideas or
    > at least what the error means?
    >

    There's nothing wrong with the above, assuming string is an alias for
    std::string, so the error is somewhere else.

    Post a minimal compilable example that demonstrates your problem.

    --
    Ian Collins.
     
    Ian Collins, Apr 22, 2007
    #2
    1. Advertising

  3. Guest

    Here is the full code (its fairly short):

    /*
    * Installer for TrainTrafficKing
    * Will allow user to install game to directory of choice
    */


    #include <iostream>
    #include <fstream>


    using namespace std;

    class install
    {
    /*void mountSource(string);
    string getDestination();
    void checkDesExists(string);
    void createDest(string);
    void installGame(string, string);
    void unmountSource(string); */

    /* Proxy Main Logic */
    /* Method Main */
    int main()
    {

    string destination;
    string source = "/mnt/TrafficKing";

    cout<<"Preparing to install Train TrafficKing..." << "/n" << "You must
    have root privileges to install this game." << "/n" << "If you do NOT
    have root privileges, please contact your System Administrator." << "/
    n" ;

    mountSource(source);
    destination = getDestination();
    createDest(destination);
    installGame(source, destination);
    unmountSource(source);
    cout << "Thank you for installing Train TrafficKing";
    }
    /* EMethod */
    /* EProxy */

    /* Proxy mountSource I/O */
    /* Method mountSource */
    void mountSource(string theSource)
    {

    string mkdir = "mkdir ";
    string source = theSource;
    string mkdirFull = mkdir + source;
    string mount = "mount /dev/cdrom -t 9660 ";
    string mountFull = mount + source;
    system(mkdirFull.c_str());
    system(mountFull.c_str());
    }
    /* EMethod */
    /* EProxy */

    /* Proxy getDestination I/O */
    /* Method getDestination */
    string getDestination()
    {
    string destination;
    cout<< "Please enter a destination to install Train TrafficKing";
    cin >> destination;
    return destination;
    }
    /* EMethod */
    /* EProxy */



    /* Proxy createDest I/O */
    /* Method createDest */
    void createDest(string theDestination)
    {
    string destination = theDestination;
    string rmdir = "rm -r ";
    string rmdirFull = rmdir + destination;
    string mkdir = "mkdir ";
    string mkdirFull = mkdir + destination;
    system(rmdirFull.c_str());
    system(mkdirFull.c_str());
    }
    /* EMethod */
    /* EProxy */

    /* Proxy installGame I/O */
    /* Method installgame */
    void installGame(string theSource, string theDestination)
    {
    string destination = theDestination;
    string source = theSource;
    string copy = "cp -R ";
    string copyFull = copy + source + " " + destination;
    system(copyFull.c_str());
    }
    /* EMethod */
    /* EProxy */

    /* Proxy unmountSource I/O */
    /* Method unmountSource */
    void unmountSource(string theSource)
    {
    string source = theSource;
    string unmount = "unmount ";
    string unmountFull = unmount + source;
    string rmdir = "rmdir ";
    string rmdirFull = rmdir + source;
    system(unmountFull.c_str());
    system(rmdirFull.c_str());
    }
    /* EMethod */
    /* EProxy */

    /* End Installer */
    }
     
    , Apr 22, 2007
    #3
  4. Ian Collins Guest

    wrote:
    > Here is the full code (its fairly short):
    >

    I can see two reasons why it won't compile:

    > int main()
    > {
    >
    > string destination;
    > string source = "/mnt/TrafficKing";
    >
    > cout<<"Preparing to install Train TrafficKing..." << "/n" << "You must
    > have root privileges to install this game." << "/n" << "If you do NOT
    > have root privileges, please contact your System Administrator." << "/
    > n" ;
    >
    > mountSource(source);
    > destination = getDestination();
    > createDest(destination);
    > installGame(source, destination);
    > unmountSource(source);
    > cout << "Thank you for installing Train TrafficKing";
    > }


    Missing return.
    > /* End Installer */
    > }
    >

    Missing semicolon.

    --
    Ian Collins.
     
    Ian Collins, Apr 22, 2007
    #4
  5. Salt_Peter Guest

    On Apr 22, 5:57 pm, wrote:
    > Here is the full code (its fairly short):
    >
    > /*
    > * Installer for TrainTrafficKing
    > * Will allow user to install game to directory of choice
    > */
    >
    > #include <iostream>
    > #include <fstream>
    >
    > using namespace std;
    >
    > class install
    > {
    > /*void mountSource(string);
    > string getDestination();
    > void checkDesExists(string);
    > void createDest(string);
    > void installGame(string, string);
    > void unmountSource(string); */
    >
    > /* Proxy Main Logic */
    > /* Method Main */
    > int main()
    > {
    >
    > string destination;
    > string source = "/mnt/TrafficKing";
    >
    > cout<<"Preparing to install Train TrafficKing..." << "/n" << "You must
    > have root privileges to install this game." << "/n" << "If you do NOT
    > have root privileges, please contact your System Administrator." << "/
    > n" ;
    >
    > mountSource(source);
    > destination = getDestination();
    > createDest(destination);
    > installGame(source, destination);
    > unmountSource(source);
    > cout << "Thank you for installing Train TrafficKing";}
    >
    > /* EMethod */
    > /* EProxy */
    >
    > /* Proxy mountSource I/O */
    > /* Method mountSource */
    > void mountSource(string theSource)
    > {
    >
    > string mkdir = "mkdir ";
    > string source = theSource;
    > string mkdirFull = mkdir + source;
    > string mount = "mount /dev/cdrom -t 9660 ";
    > string mountFull = mount + source;
    > system(mkdirFull.c_str());
    > system(mountFull.c_str());}
    >
    > /* EMethod */
    > /* EProxy */
    >
    > /* Proxy getDestination I/O */
    > /* Method getDestination */
    > string getDestination()
    > {
    > string destination;
    > cout<< "Please enter a destination to install Train TrafficKing";
    > cin >> destination;
    > return destination;}
    >
    > /* EMethod */
    > /* EProxy */
    >
    > /* Proxy createDest I/O */
    > /* Method createDest */
    > void createDest(string theDestination)
    > {
    > string destination = theDestination;
    > string rmdir = "rm -r ";
    > string rmdirFull = rmdir + destination;
    > string mkdir = "mkdir ";
    > string mkdirFull = mkdir + destination;
    > system(rmdirFull.c_str());
    > system(mkdirFull.c_str());}
    >
    > /* EMethod */
    > /* EProxy */
    >
    > /* Proxy installGame I/O */
    > /* Method installgame */
    > void installGame(string theSource, string theDestination)
    > {
    > string destination = theDestination;
    > string source = theSource;
    > string copy = "cp -R ";
    > string copyFull = copy + source + " " + destination;
    > system(copyFull.c_str());}
    >
    > /* EMethod */
    > /* EProxy */
    >
    > /* Proxy unmountSource I/O */
    > /* Method unmountSource */
    > void unmountSource(string theSource)
    > {
    > string source = theSource;
    > string unmount = "unmount ";
    > string unmountFull = unmount + source;
    > string rmdir = "rmdir ";
    > string rmdirFull = rmdir + source;
    > system(unmountFull.c_str());
    > system(rmdirFull.c_str());}
    >
    > /* EMethod */
    > /* EProxy */
    >
    > /* End Installer */
    >
    > }


    What follows is not a class:

    class A
    {
    }

    But this is:

    class A
    {
    };

    You should
    #include <string>
    if you plan to use std::string and pass it by reference to functions
    or you'll end up invoking std::string copy ctor unneccessarily. Not to
    mention that you'ld be modifying a local only.

    void foo( std::string& r_s ) // or const std::string&
    {
    // do stuff with r_s
    }

    All of the above is basic, fundamental, unavoidable, required
    knowledge.
    What book are you reading?
     
    Salt_Peter, Apr 23, 2007
    #5
    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. Yan
    Replies:
    0
    Views:
    1,171
  2. Jack Wright
    Replies:
    5
    Views:
    663
    Shiv Kumar
    Jan 19, 2004
  3. Ram
    Replies:
    0
    Views:
    2,933
  4. Andrey Batyuck

    Compiler compiler with C++ as output

    Andrey Batyuck, May 11, 2004, in forum: C++
    Replies:
    3
    Views:
    457
    Frederik Hertzum
    May 17, 2004
  5. RickMuller
    Replies:
    4
    Views:
    752
    Alexey Shamrin
    Mar 26, 2005
Loading...

Share This Page