temporary-objects

C++ destruction of temporary object in an expression

Given the following code: #include <iostream> struct implicit_t { implicit_t(int x) : x_m(x) { std::cout << "ctor" << std::endl; } ~implicit_t() { std::cout << "dtor" << std::endl; } int x_m; }; std::ostream& operator<<(std::ostream& s, const implicit_t& x) { return s << x.x_m;...

Why do C++ allow constant to be transformed to reference argument in another method?

void outputString(const string &ss) { cout << "outputString(const string& ) " + ss << endl; } int main(void) { outputString("constant tranformed to reference argument"); //! outputString(new string("abc")); new only return pointer to object return 0; } Since its prohibited to create temporary object reference transform...

Calling temporary object’s methods gives compiler error with older c library.

Hi everybody! I have a strange problem with my code when porting from a computer with glibc-2.5-25 (suse 10.2) to a computer with glibc-2.3.2-6 (suse 8.2). I use several method calls on temporary objects and they are not working on the older machine. class A { public: A(int n) {} void method() {} }; int main() { A(10).meth...

sqlite: temporary table/view in a read-only db?

It seems that sqlite won't allow me to create a temporary view in a read-only db. Am I missing something? If it's TEMPORARY, I figured db connection mode shouldn't matter. I even specified "PRAGMA temp_store = MEMORY" -- it didn't help. Is there a reasonable alternative to using views? ...

Chaining methods and temporary variables, please clarify

Greetings, everyone! I have a class that receives a pointer to a "circle" (for example) and then adjusts its attributes via some "chaining" methods. Something like this: class CCircleSetter { public: explicit CCircleSetter( CCirclePtr circle ) : m_circle(circle) { } CCircleSetter & Radius( int radius ) { if (m_ci...