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

Call Screen statement Error
Dear Experts,

is there any setting that needs to be done before creating any dialog progr

passing data from one page to another
hey guys
i have the follwoing code to get information from one page and place on another:

user administration
Dear @all,

what I have to do to set the user defaults for new users. At the moment I woul

why does my session end?
my connect.php starts the session just so you know
i can navigate arround my site fine except whe

disable all input buttons
Hello Friends,

suppose i do have a file ( file.php ) has a submit button

Code: [Sele

php slowing my site?
Hi all,

I think that one of the reasons that my site doesn't work fast is that the code is ve

Displaying Multidimensional Arrays...about to put my head in a vice, PLEASE HELP
I am fairly new to PHP and MySQL and I have a problem which I have been trying to resolve for days.

$get problem
Hi Guys ...

can you please tell me what i am doing wrong here
Code: <?php

how can i make a .gif images for my site
Dear Friends ,

Pls solve my problem , I am starting making new site but i dont know how can i

Search with relational database
Hey,

I have quite a complicated (for me anyway ) relational database for an apartments syste

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