C++ unknown syntax error -
so started learning c++ , can't life of me figure out wrong here.
this code in it's entirety. compiler not give me errors, suspect has fact "mixing" integers , strings. tried converting it, way did highly insufficient had 3 times amount of variables, didn't work. need point me in right direction. 
from top bottom:
get rid of #include "stdafx.h". windows include don't need program.
to read std::in need use operator >> not <<.  change
cin << b; to
cin >> b; last not least. assume want write "5 + [whatever value b is] = [result]", right? convert different types string can either use std::ostringstream , insert values there so:
std::ostringstream oss; oss << << " + " << b << " = "; addprinted = oss.str(); and call method str() convert content string or can directly output them std::cout (since think trying achieve)
std::cout << << " + " << b << " = " << ab; also practice not use using namespace std when posting code somewhere else. in small program may not problem hard deduce whether using e.g. std::string or custom class happens named string well. 
Comments
Post a Comment