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

what business processes?
Hi,

A general question. What business processes (like OTC - Order to Cach, P2P, R2R etc)

parameter passing issue on function
Well I thought I had created a pretty slick web page, using ?page and $_GET to load pages which wher

Best way to read this text file.
Hi.I am planning to make a small application in C# to convert the players from Football manager 2010

How to separate records and ORDER BY
Let say i have 100 records and displayed in one page, then i want to get the records from 50-100 and

isset undefined variable
Hi all,

Hope someone can point out the obvious. I've a log in script, if you dont enter a use

browse folder only
hi,
is there a way i can browse or get the directory or folder only and not the file?
i just w

getAlexaRank($url) function not working
I have made a function to get alexa rank
the site is here: http://mytestsite.rack111.com/1

Handling text changed in text box control using Ajax
I need to create a web form with a text box control. When someone types text into the textbox I nee

Captcha problem users just refresh and it will let them auto submit again
Users will just re submit and not have to enter the new captcha.. ? Lol but if i refresh the page, t

Perplexing problem showing a .jpg
Please disregard..........I figured it out

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