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

Serial number of exernal hard disk/Thumbdrive
Hi guys, I am new tio java networking concepts.Please tel me how to get Serial number of exernal

SAP FICO learning materials
Hi all,
I am new to this world of SAP FICO. I have taken training on SAP FICO, but was wonderin

Custom CMS
This is a big custom CMS script I'd like to develop and would like some help atleast figuring out wh

How to store checkbox array in a session, and then be able to add to it?
I'm trying to store an array of checkbox values into a session array, sort of like a shopping cart,

using explode() to fill in checkboxes
Hi

I have a field stored in a table that contains regions in the UK separated by commas. Ther

pop3 and fsockopen
So I am able to connect to the pop3 server, log in, and check how many messages there are. I am hav

very easy question about SQL info
Hello,
I think that I have a very easy question.
I know how to create a form using php SQL and

Bar charts using Graphical Framework.
I am using Graphical Frameworks(GFW) to create a chart Graphic . There is no problem with the data d

Creation of Raw Exposure manually
SAP Gurus

I am creating Raw Exposure ( Hedge management ) thru T Code TEM10 with followin

How to use Substr
I want to check for the word CATEGORY: inside a string which can be CATEGORY: ITEM
and remove 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