I keep getting a compilier error whenever I run this… I am quite sure it is just something stupid that I am overlooking, so I though I would let you guys try.
#include <iostream>
#include <string>
using namespace std;
class hi
{
public:
string run()
{
hi = "Hello.";
return hi;
}
private:
string hi;
}
int main()
{
bool end = false;
string in = "";
string out = "";
hi hi;
while(end != true)
{
cout << "Input a Command: ";
cin >> in;
// if(in == "help")
// {
// out = help.run;
// }
if(in == "hi")
{
out = hi.run;
}
cout << out;
in = "";
}
return 0;
}
I keep getting these errors:
|6|error: new types may not be defined in a return type|
|6|note: (perhaps a semicolon is missing after the definition of 'hi')|
|18|error: two or more data types in declaration of 'main'|
||=== Build finished: 2 errors, 0 warnings ===|
Near the end of your program you are closing more curly brackets than you have opened. You need to remove the curly bracket right before
return 0;Also you need to terminate your definition of
class hiwith a semicolon after the closing curly bracket, right before the definition ofmain().