编译错误 [英] Compiler Error
问题描述
我在编译时收到此错误
输入结束时预期的非限定ID。
这是生成的代码块错误:
/ *代理unmountSource I / O * /
/ *方法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 * /
编译器指向具有结束大括号的行。任何想法或
至少是错误的含义?
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?
推荐答案
el ***** @ gmail.com 写道:
我收到此错误编译
输入结束时的预期不合格ID。
以下是产生错误的代码块:
/ *代理unmountSource I / O * /
/ *方法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 * /
编译器指向具有结束卷曲b的行种族。任何想法或
至少是错误意味着什么?
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?
上面没有任何问题,假设字符串是别名
std :: string,所以错误发生在其他地方。
发布一个最小的可编译示例来证明你的问题。
-
Ian Collins。
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.
这是完整代码(相当简短):
>
/ *
* TrainTrafficKing的安装程序
*将允许用户将游戏安装到所选目录
* /
#include< iostream>
#include< fstream>
使用命名空间std;
class install
{
/ * void mountSource(string);
string getDestination();
void checkDesExists (字符串);
void createDest(string);
void installGame(string,string);
void unmountSource(string); * /
/ *代理主逻辑* /
/ *方法主* /
int main()
{
字符串目的地;
string source =" / mnt / TrafficKing" ;;
cout<<"准备安装Train TrafficKing ... << " / N" << 你必须
拥有root权限才能安装此游戏。 << " / N" << 如果你没有
有root权限,请联系你的系统管理员。 << /
n ;
mountSource(来源);
destination = getDestination();
createDest(destination);
installGame(来源,目的地);
unmountSource(来源);
cout<< 感谢您安装Train TrafficKing;
}
/ * EMethod * /
/ * EProxy * /
/ *代理mountSource I / O * /
/ *方法mountSource * /
void mountSource(string theSource)
{
string mkdir =" mkdir";
string source = theSource;
string mkdirFull = mkdir +来源;
string mount =" mount / dev / cdrom -t 9660" ;;
string mountFull = mount + source;
system (mkdirFull.c_str());
system(mountFull.c_str());
}
/ * EMethod * /
/ * EProxy * /
/ *代理getDestination I / O * /
/ *方法getDestination * /
string getDestination()
{
string destination;
cout<< 请输入目的地以安装Train TrafficKing;
cin>目的地;
返回目的地;
}
/ * EMethod * /
/ * EProxy * /
/ *代理createDest I / O * /
/ *方法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 * /
/ *代理安装游戏I / O * /
/ *方法installgame * /
void installGame(string theSource,string theDestination)
{
string destination = theDestination ;
string source = theSource;
string copy =" cp -R" ;;
string copyFull = copy + source +" " +目的地;
系统(copyFull.c_str());
}
/ * EMethod * /
/ * EProxy * /
/ *代理unmountSource I / O * /
/ *方法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 * /
}
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 */
}
el*****@gmail.com 写道:
这是完整的代码(相当简短):
Here is the full code (its fairly short):
我可以看到两个不能编译的原因:
I can see two reasons why it won''t compile:
int main()
{
字符串目的地;
string source =" / mnt / TrafficKing" ;;
cout<<"准备安装Train TrafficKing ...... << " / N" << 你必须
拥有root权限才能安装此游戏。 << " / N" << 如果你没有
有root权限,请联系你的系统管理员。 << /
n ;
mountSource(来源);
destination = getDestination();
createDest(destination);
installGame(来源,目的地);
unmountSource(来源);
cout<< 感谢您安装Train TrafficKing;
}
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 * /
}
/* End Installer */
}
缺少分号。
-
Ian Collins。
Missing semicolon.
--
Ian Collins.
这篇关于编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!