My professor is having me write a chat bot and i keep getting an error saying "undeclared identifier." I am new to programming and could use some help.
this occurs on line 49.
sorry if this is hard to follow. i'm also new to the forum.
#include <iostream> // for getline(), cout, cin
#include <string>
usingnamespace std;
bool processInput(string); // prototype for user input function
void idk (int); // prototype for misunderstood input
int main()
{
// 1. declare and initialize variables
bool keepgoing = true;
bool understand = true;
string userinput;
string name;
int (idontknow) = 1;
// cout << idontknow << endl;
// 2. prompt for first input
// . get name of user
cout << "Hello, I am Chatbot. What is your name?\n" << "> ";
getline (cin,name);
cout << "Hello " << name << "!\n";
// 3. while no response of "bye" or "Bye"
while(keepgoing)
{
cout << "> ";
// 3a. Get user input
getline (cin,userinput);
// 3b. Process user input and set keepgoing flag
keepgoing = processInput(userinput);
}
}
bool processInput(string userinput)
// pre: userinput has been declared and initialized (can contain "")
// post: chatbot response has been printed/output and true/false has been returned
{
if (userinput == "Hello" || userinput == "hello" || userinput == "hi") {
cout << "We've already passed this part, can we move on?\n";
}
elseif (userinput == "what is the meaning of life") {
cout << "Easy!... 42";
}
// cout << "you said ..." << userinput << endl;
// std::cout << "people who say that are idiots" << std::endl;
elseif (userinput == "Bye" || userinput == "bye") returnfalse;
else idk(int (idontknow));
returntrue;
}
void idk(int (idontknow))
{
if (idontknow == 1) {
cout << "I dont understand\n";
}
if (idontknow == 2) {
cout << "Say what? I'm confused\n";
}
if (idontknow == 3) {
cout << "I dont understand\n";
idontknow = idontknow - 3;
}
idontknow++;
}
When I remove the parentheses from (idontknow) it gives me an error "expected '(' for function-style cast or type construction" also on line 49. Or are you referring to something else?