temporary objects


Posted on 16th Feb 2014 07:03 pm by admin

Until now i thought every temporary object in C++ is created as constant. I'm wondering why my compiler (gcc) is reporting an error on line k.f();, but not g().f(); and g() = k;. Does anyone know?

#include

class K
{
public:
K(){}
void f(){}
};

K g()
{
K k;
return k;
}

int main()
{
const K k;
k.f();
g().f();
g() = k;
}

No comments posted yet

Your Answer:

Login to answer
91 Like 50 Dislike
Previous forums Next forums
Other forums

xApp Analytics in BI 7.0
Dear all,

I am trying to implement xApp Analytics in BI 7.0. After I installed the analyt

rename the file
File.txt

Code: ***DOCUMENT***
..DN:
000044255
..CB:
..SN:
..PY:
2009
..E

Sql and php order list script problems
Hi im having a few problems with trying to get the coding right on a orders list ive done (or trying

MSSQL/PHP
I am tryint to setup a webapplication developed in PHP, Apache2.0 and SQLServer2000 as backend which

Schedule editor
Hi,

I have a question related to Schedule editor.
If we schedule a BLS for every 30

Display thumbnails as square while retaining aspect ratio
I am trying to figure out a way to make an image display as a square, for example 80x80 pixels, when

Big Problem!! Please help
Hi Guys,

Im making a website for a friend have encountered a really annoying problem. When ev

Adding Different Numbers From MySQL
Basically I have a mysql database with a couple prices as the following:

9.99
9.99
9.99

recrawling
Can anyone suggest me how may i know a page is updated before it is being downloaded, so that i can

Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash