I am writing a program project for class and having difficulties with creating a value returning function that reads in a integer value, takes that value compares it in array of words then takes these words from the array and stores it in a string. I believe if it will run it should return the string value,
but now my program will not even compile.
here is the fuction prototype, header and function call that I have written:
string convertDollars(int); // prototype NOTE: this is on Line 19
i believe the complier doesnt like something to do with the way i have written these.. this is the error i get below when I try to Build..the error seems to associate where i have the prototype for my function listed..
1>------ Build started: Project: project4, Configuration: Debug Win32 ------
1> project4.cpp
1>c:\users\neo\documents\visual studio 2010\projects\project4\project4\project4.cpp(19): error C2146: syntax error : missing ';' before identifier 'convertDollars'
1>c:\users\neo\documents\visual studio 2010\projects\project4\project4\project4.cpp(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\neo\documents\visual studio 2010\projects\project4\project4\project4.cpp(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
" There are alot more errors here when I build, but they seems to be because of the the ones i have listed."
Seeing the whole code would help greatly. What you've asked is the equivalent of "Fill in the missing words: How much <> <> <> <> chuck <> a <> <> chuck <>"
Having said that, you could put a std:: in front of all the strings.
Thanks Jim, that worked but i didnt think it was needed, for some reason I thought visual studio added it in.. I guess i dont understand why that worked?
If you put the following line somewhere near the top of your file (after #include <iostream>), you'll not need the std:: in front of the strings.
usingnamespace std;
It's because you need to tell the compiler where everything is - absolutely everything. If you remember that the compiler is generally incapable of intelligent thought, and spell everything out to it, generally you'll be OK.