First of all it is unclear what type name has. If it has the type std::string
then instead of
string nametext;
nametext = "Your name is" << name;
you should write
std::string nametext = "Your name is " + name;
where operator + serves to concatenate strings.
If name
is a character array then you may not use operator + for two character arrays (the string literal is also a character array), because character arrays in expressions are implicitly converted to pointers by the compiler. In this case you could write
std::string nametext( "Your name is " );
nametext.append( name );
or
std::string nametext( "Your name is " );
nametext += name;