View Full Version : Illegal function definitions in "DoYouLikeThree()"

02-19-2005, 08:27 PM
Hello, I am having some problems with this piece of code.

char User_Decision;
void DoYouLikeThree(){
cout << "Do you like the number 3? (Yes=Y, No=N)" << endl;
cin >> User_Decision;
if (User_Decision=y){
cout << "You are cool" << endl;
else {
if (User_Decision=n)
cout << "You are uncool" << endl;


What am I doing wrong? (This is just a portion of the program, I have #include <iostream> which should have all the definitions for cout, etc.

02-19-2005, 09:49 PM
Have you added the line "using namespace std" under "#include <iostream>"? You will need that or "using std::cout" and "using std::cin" to be able to use cin and cout.

Once you get that working, you can search for the difference between "=" and "==", and also learn about comparing strings.

02-19-2005, 10:21 PM
Yeah, I have added using namespace std; and I noticed the == mistake and changed that...I don't know why I used a normal equal sign, I know that it is used in giving variables a value.

I have other parts in that program that use "cout" and "cin," and they work just fine, so adding the std's at the top wont really fix anything.

02-20-2005, 02:07 AM
As long as you have something like "if (User_Decision == 'y')", that function should be fine.

If you still get illegal function definition error, check the function above it for misplaced/missing braces.

Dr. Evil
02-20-2005, 07:44 AM
You might also want to check it with an toupper(), so it will respond correctly to both upper case and lower case values:

if(toupper(character) == 'Y') ;

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum