Hi can anyone help me with some errors I'm getting in my program? Here is the code...
#include <iostream>
#include <string>
using namespace std;
bool intro(void)
string name = " ";
int _tmain(int argc, _TCHAR* argv[])
{
intro(void);
return 0;
}
bool intro(void)
{
using std::cout;
using std::cin;
cout << "Hi! What is your name? \n"
cin >> name;
cout << "Hello!"<< name;
cout << "We need you to defeat the evil dragon.\n";
cout << "To do this you will need to make a great journey.\n";
cout << "And then defeat the dragon at its source!\n";
cout << "Will you accept the challenge?\n";
cout << "1) Yes. \n";
cout << "2) No. \n\n";
int reply;
cin >> reply;
return !(reply == 1);
}
and the errors...
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(8) : error C3646: 'string' : unknown override specifier
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(8) : error C3646: 'name' : unknown override specifier
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(8) : error C2072: 'intro' : initialization of a function
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(8) : error C2440: 'initializing' : cannot convert from 'const char [2]' to 'bool (void)'
1> There are no conversions to function types, although there are conversions to references or pointers to functions
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(14) : error C2144: syntax error : 'void' should be preceded by ')'
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(14) : error C2059: syntax error : ')'
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(23) : error C2146: syntax error : missing ';' before identifier 'cin'
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(23) : error C2065: 'name' : undeclared identifier
1>c:\users\user\documents\visual studio 2008\projects\my new quest\my new quest\my new quest.cpp(24) : error C2065: 'name' : undeclared identifier
1>Build log was saved at "file://c:\Users\User\Documents\Visual Studio 2008\Projects\MY NEW QUEST\MY NEW QUEST\Debug\BuildLog.htm"
If you could tell me what I'm getting wrong thanks!
#include <iostream>
#include <string>
usingnamespace std;
bool intro();
string name = " ";
int main( )
{
intro();
return 0;
}
bool intro()
{
using std::cout;
using std::cin;
cout << "Hi! What is your name? \n";
cin >> name;
cout << "Hello!"<< name;
cout << "We need you to defeat the evil dragon.\n";
cout << "To do this you will need to make a great journey.\n";
cout << "And then defeat the dragon at its source!\n";
cout << "Will you accept the challenge?\n";
cout << "1) Yes. \n";
cout << "2) No. \n\n";
int reply;
cin >> reply;
return !(reply == 1);
}
Also.... I don't see why your using a function. Thats really unnecessary. Just copy-and-paste the code from the intro function you wrote and put it in your main function.