   missing ''? (operator overloading)
  This program was made so that I could practice operator overloading and a seemingly simple problem is baffling me. The error is for each of the three lines in my ostream function and it reads, missing ';' before 'std::cout'. Here is the code:#include <iostream>#include <string>class heavyarmor{friend std::ostream& operator<<(std::ostream& os, heavyarmor& passedha);public:heavyarmor(const std::string armorname = ""): m_armorname(armorname) {}int m_resistance;int m_weight;void displaystats();std::string getname() { return m_armorname; }private:std::string m_armorname;};void heavyarmor::displaystats(){std::cout << "heavyarmor's stats:\n";std::cout << "Chainmail:\tArmor resistance : " << m_resistance;std::cout << "\tArmor weight : " << m_weight;}std::ostream& operator<<(std::ostream& os, heavyarmor& passedha);int main(){heavyarmor chainmail("Orogulf's Bright Chain Vest");chainmail.m_resistance = 3;chainmail.m_weight = 5;chainmail.displaystats();std::cout << chainmail;return 0;}std::ostream& operator<<(std::ostream& os, heavyarmor& passedha){os std::cout << "\nCalling chainmail's name with the overloaded";os std::cout << " operator (.)\n";os std::cout << "\tArmor name : " << passedha.getname();return os;}
  remove the std::cout. i think you'll be fine then.std::ostream& operator<<(std::ostream& os, heavyarmor& passedha){os << std::endl << "Calling chainmail's name with the overloaded";os << " operator (.)" << std:endl;os << "\tArmor name : " << passedha.getname();return os;}In C++, it's better and standard to use std::endl to cause a newline than "\n". Unless you have a reason why you don't want the stream buffer flushed.   ;Quote:Original post by Alpha_ProgDesIn C++, it's better and standard to use std::endl to cause a newline than "\n". Unless you have a reason why you don't want the stream buffer flushed.Actually, it's better to use '\n' for the intermediate newlines and keep std::endl for the last one. When writing an overloaded stream insertion operator, using '\n' internally is probably preferable: leave the decision for flushing the output to the user of the class -- unless you are writing a lot of data (in which case it would get flushed anyway).   ;Quote:Original post by FrunyQuote:Original post by Alpha_ProgDesIn C++, it's better and standard to use std::endl to cause a newline than "\n". Unless you have a reason why you don't want the stream buffer flushed.Actually, it's better to use '\n' for the intermediate newlines and keep std::endl for the last one. When writing an overloaded stream insertion operator, using '\n' internally is probably preferable: leave the decision for flushing the output to the user of the class -- unless you are writing a lot of data (in which case it would get flushed anyway).That's basically what I heard. I heard '\n' has less overhead, and to use std::endl at the end to prevent formatting problems.;  Two more questions, when trying to run from console, I get to my debug folder that contains the .exe, but when I get to the debug directory in the console, I type in the name of the exe and its say it cannot recognize it as a command.Second, how do I make a shortcut to a directory running from console.   ;Quote:Original post by kevtimcTwo more questions, when trying to run from console, I get to my debug folder that contains the .exe, but when I get to the debug directory in the console, I type in the name of the exe and its say it cannot recognize it as a command.Because you say ".exe", I assume Windows (thus a DOS window).- Does the .exe appear when you 'dir' in that directory?- Try it including the .exe extension.- Try specifying it as .\{name of exe}.Quote:Second, how do I make a shortcut to a directory running from console.I'm not really sure what you mean.   ;Quote:Original post by kevtimcSecond, how do I make a shortcut to a directory running from console.If you go to your start menu to accessories, then right click on the Command Prompt icon and do Sent To -> Desktop (Create Shortcut), it will (dur) place a shortcut to your command prompt on the desktop.If you then right click the shortcut, in properties you should see an edit box labelled "Start In" or something, which will be the Windows directory or your My Documents directory, or just blank, by default. Can't rememberType the complete path to your project's folder in here and click OK. When you double click this shortcut, it should now open in your project folder.This will only apply to this specific shortcut and other Command Prompt icons will still behave as before.HTH Paul   ;Quote:Original post by ZahlmanQuote:Original post by kevtimcTwo more questions, when trying to run from console, I get to my debug folder that contains the .exe, but when I get to the debug directory in the console, I type in the name of the exe and its say it cannot recognize it as a command.Because you say ".exe", I assume Windows (thus a DOS window).- Does the .exe appear when you 'dir' in that directory?- Try it including the .exe extension.- Try specifying it as .\{name of exe}.-Yes-Didn't work-Don't understand;  Very strange. So, when you type dir, your program appears in the list as "name.exe", but if you type "name" or "name.exe" it says it can't recognise the command?Zahlman is suggesting you type .\name.exe, which would equate to c:\the_full_current_directory\name.exe, although if the name on its own isn't working, I don't see why that would. I'm not saying it is not worth a try, but would be very very weird if that worked, but the name on its own didn't.Just to clarify, we are talking Windows? We are talking either MS-DOS Prompt (Win98 etc) or Command Prompt (2000, XP etc)?If I was in C:\Paul, and there was an exe called MMORPG.exe in that directory, the commands would look (a bit) like this:C:\Paul> dirContents of C:\Paul or some such nonsense. <dir>.. <dir>MMORPG.EXE Size Blah blah blah MMORPG.exeTotal size: whatever blah blahC:\Paul> MMORPGWelcome to the ultimate MMORPG. Press a key to exit.xThank you for playing.C:\Paul> etc...Does that tally with what you are seeing (except for my improvised bits, obviously)? Very weird if so.[EDIT]Just to clarify, here is a screenshot of me navigating to a directory and running a file called x.exe from XP Command Prompt, in case it helps:;  Yeah, your right. :P And I'm in XP.   