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

Thread in PHP
Thread in PHP
Some basic use and basic code for thread in php
This is my question?

problem with refreshing
in my site, i have an index page, it has a main div. this main div's content is changing according t

Preloading images
Posting this question here because I am not sure where this should belong.I am building an asp.net a

How can I get my program to read a larger array ??
Hi:

I have this program that reads from an array to do calculations. The array are just t

Changes to hosting company's server has affected web contact form
I started a thread a couple of months ago about the contact forms on my client's website. Basically

php redirecting
i wont open a new thread but i have a question about redirecting....
i wonder why my code doesnt

Displaying an image using echo command
I had done a query on my database, one of the fields being an image reference to a directory where a

search function
HI guys,

if anyone could point us in the right direction of how to do this, or provide some t

foreach help.
Hello all,

First time I'm attempting to use a foreach statement and was just wondering if my

php web service error
hey guys,
I'm working on a project requires the use of web services. I've been trying a few tutor

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