c++ - Difference between sending text as string and text between quotation marks -



c++ - Difference between sending text as string and text between quotation marks -

i utilize mysql++ library connect database. i've created connection , query:

connection conn(false); conn.connect("database", "localhost", "user", "pass"); query query = conn.query();

then can send query database like:

query << "select name my_table1, my_table2 age=20"

but i'd send number variable instead of 20. tried in way:

std::stringstream ss; //create stringstream ss << my_number //add number stream std::string number = ss.str(); query << "select name my_table1, my_table2 age="+number;

unfortunately, doesn't work. sec problem analogous. create qpixmap object (here qpixmap doesn't matter anyway) , i've give constructor path image:

std:string name; (...) std::string path = "/home/root/img/"+name+".png"; //name variable string qpixmap *tmp = new qpixmap(qstring::fromutf8(path.c_str())); //conversion string qstring

query << "select name my_table1, my_table2 age="+number;

should be:

query << "select name my_table1, my_table2 age=" << number;

since + not valid c++ streams concatenation operator.

what's problem qpixmap? maybe should separate question?

c++ string qt stream filepath

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -