When are temporary variables formed by c++ compiler?, C/C++ Programming

A: Provided that function parameter is "const reference", compiler create temporary variable in following two ways.

a) The actual argument is the correct type, however it isn't Lvalue

double Cube(const double & num)

{

num = num * num * num;

return num;

}

double temp = 2.0;

double value = cube(3.0 + temp); // argument is a expression and not a Lvalue;

b) The actual argument is of the wrong type, however of a type which can be converted to the correct type

long temp = 3L;

double value = cuberoot ( temp); // long to double conversion

 

Posted Date: 3/21/2013 7:28:18 AM | Location : United States







Related Discussions:- When are temporary variables formed by c++ compiler?, Assignment Help, Ask Question on When are temporary variables formed by c++ compiler?, Get Answer, Expert's Help, When are temporary variables formed by c++ compiler? Discussions

Write discussion on When are temporary variables formed by c++ compiler?
Your posts are moderated
Related Questions
Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

The Best fit algorithm: The best fit method occurs the smallest free block whose size is greater than or equivalent to n. An algorithm to get such a block by traversing the whole

Selecting Array Elements Implement the following C++ code in assembly language, using the block-structured .IF and .WHILE directives. Assume that all variables are 32-bit signed in


Ask question #write statement that assign random integer to the varaible n in the (100

Yes. "Memory pools" are useful in many situations. The bad news is that I'll need to drag you through the mire of how it acts before we talk about all the uses. Firstly, recall

Enumerated Constants Enumerated constants enable the creation of new types and then explain variables of these types so that their values are restricted to a set of possible va

Discuss the saleint featuresand application of c

Write a method (belonging to the TermStructure class) that takes a pointer to an array of bonds and an integer, representing the number of bonds in the array as arguments, and esti

SquareMaze The SquareMaze class should be declared and defined in maze.h and maze.cpp, respectively. Each SquareMaze object will represent a randomly-generated square maze and its