-3
所以我试图开始调试我的代码有什么问题,但我目前有一个问题,我不明白的错误。使用代码块通过Oracle虚拟机。我很确定问题在于我的代码的标题,但我会发布整个事情。C++错误“预期的非限定id”('令牌“在调试之前
我想构建一个使用头文件,原型, 。和功能到目前为止,我只需要基本的数学工作
错误Messege写着: || ===体形:调试在贾维斯。(编译:GNU GCC编译)=== | /家庭/用户/ Dropbox的/ Lecture36CompilationAnd内存/ JARVIS/JARVIS.h | 1 |错误:预期在''''令牌|之前的非限定ID || ===构建失败:1个错误,0个警告(0分(s),0秒(s))=== |
的main.cpp
#include <iostream>
#include <string>
#include "JARVIS.h"
using namespace std;
int main()
{
string command;
bool jarvis_running = false;
cout << "J.A.R.V.I.S" << endl;
cout << "Give a command from the list of commands available." << endl;
cin >> command;
if (command == "-h")
{
jarvis_running = true;
cout << "The available commands are: math" << endl;
}
if (command = "math")
{
jarvis_running = true;
math();
}
if (jarvis_running == false)
{
cout << "That command was not valid" << endl;
cout << "Type '-h' if you need to know the available commands." << endl;
}
return 0;
}
* JarvisFunctions.cpp
#include <iostream>
#include <string>
#include "JARVIS.h"
using namespace std;
int math()
{
char mathCommand;
cout << "(A)ddition, (S)ubtraction, (M)ultiplication, or (D)ivision?" << endl;
cin >> mathCommand;
if (mathCommand == "A")
{
cout << "input the two integers you are adding" << endl;
cin >> integer1 >> integer2;
math.setValues(integer1, integer2);
addition add;
}
else if(mathCommand == "S")
{
cout << "input the two integers you are subtracting" << endl;
cin >> integer1 >> integer2;
math.setValues(integer1, integer2);
subtraction sub;
}
else if(mathCommand == "M")
{
cout << "input the two integers you are multiplying" << endl;
cin >> integer1 >> integer2;
math.setValue(integer1, integer2);
mulitplication multi;
}
else if(mathCommand == "D")
{
cout << "input the two integers you are dividing" << endl;
cin >> integer1 >> integer2;
math.setValues(integer1, integer2);
division div;
}
else
{
cout << "you did not input the right fuctions, either use A, S, M, or D" << endl;
}
}
头
JARVIS.h
#ifndef JARVIS_H
#define JARVIS_H
int math();
class math
{
private:
int val1;
int val2;
public:
math()
{
cout<<"calling math constructor"<<endl;
}
void setValues (int a, int b){
val1 = a;
val2 = b;
}
~math()
{
cout<<"calling math deconstructor"<<endl;
}
};
int addition:public math
{
finalVal = val1 + val2;
return finalVal;
};
int subtraction:public math
{
finalVal = val1 - val2;
return finalVal;
};
int multiplication:public math
{
int finalVal = val1 * val2;
return finalVal;
};
int division:public math
{
int finalVal = val1/val2;
return finalVal;
};
#endif //JARVIS_H
,如果你给我们确切的情况和错误这个问题就会感觉到好了很多消息也是如此。 – xtofl 2014-12-05 12:42:12