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

How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........

$variable = $variable
Hello

Sorry if this is a really simple question but I have run out of ideas. Is there a reall

Need help with an email blocker for a guessbook
I am new with php and here is a simple guessbook page but I am being hit with spam from a group of t

Web Application Recipe
Hi Guys!

I am working with the Web Application recipes. I am currently working on the sen

cURL and Sessions
Ohai.

So, I'm trying to cURL a bunch of things off of a page, and put them into a session. I'

script and html conflict in trying to create a header.
I have an error is occurring because of an html webpage with a "php require" at the top of

Undefined variables
hi
----------------------------------------------------------------------------------------------

LinkedList help
Ok so I just learned quickly about lists, so I have a not too hard project I think, but am having a

Tree Menu
Hi guys,

Can anyone help me making a tree navigation system? I have a site where I'm allowin

How to show more than 1 users with this code...
Hello,
i have a table that shows users only if I, as Administrator, want to be shown. But its sho

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