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

help, header() is not working!
Hello, I have this code:


<?php

/**
* @author samoi
* @copyright 200

line breaks in between fetched file names
Hi,

I have this code:
Code: <?php
if($dir = opendir('files')){
while (($f

Php If in MySql query (hiding labels if a field is empty)
Okay, I've been trying to do this for a while, and I'm finally going to ask for help so I can get th

Pro-rata Billing in Periodic Billing for Rental
Hi guys,

We have a situation, where a rental contract starts at the mid of the month say

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

Checking if multidimensional array is empty?
I have a for with multiple test input fields. Specifically the user submits multiple names and ages

PHP - HTML
Could anyone give me some GOOD sample links for php - html email tutorial.

Thanks!

Sorting JTable on more than just the values listed in the columns
I have a collection of objects that store (among other things) two integer values. I only want to di

need help with this contact form
I made this form and I need it to read the data and write the data to a table and its not working ca

Need Successful Return
Hello I am currently working a form here, and I have everything figured out except when I click 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