hi guys,
I'm fairly new to C++ and have struck my first problem.
I am developing a simple program where I input a string and a float value, and they are written to a text file.
It was working fine until I've put in my if and else statements to check the inputted string and float are of a correct value.
here's my script:
here's my error when compiling:Code:#include <fstream> #include <string> #include <iostream> using namespace std ; // conflicting forces version int main() { string game = "Conflicting Forces"; float version; string stage; // enter stage cout << "Enter Conflicting Forces Version Stage" << endl; cin >> stage; if(stage == "Beta" || stage == "Alpha" || stage == "Live") { // enter version number cout << "Enter Conflicting Forces Version Number" << endl; cin >> version; if(version > 1.0 && version < 3.0) { cout << "Conflicting Forces is now version: " + stage + " " + version << endl; } else { cout << "Error: Not a valid version" << endl; } } else { cout << "Error: Not a valid stage" << endl; } ofstream writer("cf-version.txt"); if(!writer) { cout << "Error opening file for output" << endl; return -1; } else { writer << (game + " Version " + stage + version) << endl; writer.close(); } // stop window from closing after the print system("pause"); return 0 ; }
Everytime I compile a file I always get this warning:cf-version.cpp: In function `int main()':
cf-version.cpp:26: error: no match for 'operator+' in '
:basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
aits = std::char_traits<char>, _Alloc = std::allocator<
) + version'
cf-version.cpp:47: error: no match for 'operator+' in '
:basic_string<_CharT, _Traits, _Alloc>&, const std::bas
, _Alloc>&) [with _CharT = char, _Traits = std::char_tr
:allocator<char>](((const std::basic_string<char, std::
llocator<char> >&)((const std::basic_string<char, std::
llocator<char> >*)(&stage)))) + version'
cf-version.cpp:54:2: warning: no newline at end of file
however it doesn't appear to affect my program, is there a simple solution to get rid of this warning?cf-version.cpp:54:2: warning: no newline at end of file
and what do I need to change to get rid of the rest of the errors?
sorry for the not so well formatted error. I am compiling in command prompt using MinGW on Windows
thanks for any help in advance
Regards ACE