Hi, I have recently started to read some C++ books, and i came across this in the "C++ for dummies"(obviously apt for myself) the following example on Mixed Mode Expressions.
So i wrote a little output to test, and i cannot seem to get anything other than 1 as my output. Is this correct?Code:// in the following expression the value of nValue1 // is converted into a double before performing the // assignment int nValue1 = 1; nValue1 + 1.0;
I would of expected from the comments from the book excerpt above suggest that the integer is converted to a float either as, 1.0 or perhaps if i squint hard it should of returned an integer of 2.
So can anyone explain what I've interpreted or coded incorrect and shed some light on the subject.?
Code:#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main (int nNumberofArgs, char* pszArgs []) { int nValue = 1; nValue + 1.0; cout << nValue << endl; system ("PAUSE"); return 0;



LinkBack URL
About LinkBacks





