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

Mail Form receiving emails with no content
Hi, I hope someone here can help me.
I have a simple form in my website, it was working OK, after

Sum of Values in an Array
This is probably really simple... but it's been years since I've written anything, so bare with me!<

php mail form text wont appear / javascript included
Guys/gals...

I am running into a problem whereby I have a great piece of javascript code that

PHP Mysql Staff Induction System
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi

Customizing message/behavior
Hi,I'm using the ASP.NET membership/authorization controls in my application. Some parts of my appli

Amatuer requiring assistance
Beginner and amateur in need of assistance

My Site - (Spare Parts for Domestic Appliances)

Include ("Absolute Path") of a file?
I'm not sure what I'm doing wrong. I am writing my php code in the same directory of the file that

Add User script "Could not execute query"
This should be an easy script but I can't get it to run. Can someone please help me?

<

FAGL_FC_TRANSLATION FAS52 New GL ECC 6.0
Hello,

The new program for Translating GL Balances (FAS 52) gives the option to use diffe

This must be easy , pulling the last record of the day, every day, from a txt
I have a txt file logging weather data every minutes (so 1 record per minute). I want to extract the

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