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

Bandwidth monitoring?
Hi guys,

I need a little information I have written a php app and I occurred to that I need

Problem with shopcart code
Hello, I am having a bit of trouble being able to add a product to my shopcart. My mysql database i

Time-based image rotation script
I'm trying to write a PHP script that rotates an image based on what time of day it is. I want the

Standard DES encryption script?
Can anybody point me to a tutorial or a short script that shows how to encrypt some text with salt i

printing links
Hi every1

i am connecting to a table in sql and the looping through with a while ($ var = my

form problem
Hi all, I think this is going to be easy to resolve but for I have been looking at it to long and I

utl_file open error
i have file in the unix path

Path /popdev01/pop/popdevb/tfi/

File name

cyrillic string conversion question
Hello,

First time here...

I would like to know if there is a way to convert a

Interpret Order
Hello all,

I'm wondering if I have this:

Code: $switch = array(
'one' =>

How to read posted binary data from a mobile device and post it to a web server?
Here is the senario...

I have a mobile device (MD) that posts binary data to a Web Server (WS

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