I wanted to learn c++, so I attented to a c++ programming course. Mostly it's pretty simple stuff, but now I've ran couple times into this weird situation where I can't use '<<' operands to pass std::string into ostream, even though most of the times I'm able to do so.
As an IDE I am using vs2015 and I have the following code.
#include "stdafx.h"
#include <iostream>
int main()
{
std::string str = "Foo";
std::cout << str << std::endl;
}
What happens is that the '<<' operands between std::cout and str get redlined and I get error message saying: "no operator "<<" matches these operands. Operand types are: std::ostream << std::string".
This happens quite randomly and rarely, so I haven't been able to figure out any type of correlation between the cases. One thing I noticed is that including <sstream>
to the project will get rid of the problem, but I don't think thats how it should be.
Any suggestions?