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

having a small php error tha deals with the 'foreach'
Last night i was working on a script for a cart and it seemed to working good, until this morning. F

Socket problem
Hello,

Earlier I posted about my problem with my socket script. It took up to 100% CPU usage.

New Search Engine problem
Hey everyone,

I have a ZIP Code Radius search engine already functional. it displays all of t

TimeZoneOffset
Hello,

Please i need your help. I have a system that users can use to punch in and out. This

How can I uploading Transactional Data from Legacy to New SAP system
Hell Gurus,

I am overwhelmed with questions on how to migrate huge volume of Sales Orders

Loops and Classes
I am making a template system and everything seems to be going well up until I have to loop in a var

How do I use a global footer..?
If my index.php has a bole bunch of if functions and exit's in them

PHP template help
Ok, I don't know if anyone can help me but I am using PHP templates to make a site. I am a newbie an

SAP Logon Failed
I tried to login to SAP through MMC.

When i click start and give password.

it

progress bar...need expert opinion of experienced webmaster
Hey guys, quick question:

I want to display a progress bar when I upload files, but I am not

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