why dosn't this work?

im trying my own experiment with my C++ program. acording to what i just learned in my C++ book for dummys.. this should work yet dosen't. the code is in the lines it should be in for it with #include <iostream> as line 1

#include <iostream>

using namespace std;

int main()
{
int tom, dick, harry;
tom = 10;
dick = 20;
harry = 3254;
cout << tom, dick, harry << endl;
return 0;
}


after this is entered i build yet the error i come up with is

||=== variable, Debug ===|
C:\Documents and Settings\kitane\Desktop\variable\main.cpp||In function `int main()':|
C:\Documents and Settings\kitane\Desktop\variable\main.cpp|11|error: invalid operands of types `int' and `<unknown type>' to binary `operator<<'|
||=== Build finished: 1 errors, 0 warnings ===|




so... whats missing or removed? thanks!
Variables to cout are passed just like endl in your example (they must be separated with insertion operator << ) so line 11 should be cout << tom<<dick<< harry << endl;

Btw, use [co de][/co de] tags (without spaces) to make source code more readable.
Last edited on
ok i see thanks for the help. now is there a way to space the numbers when you run them? i tryed

cout << tom << dick << harry << endl;

like i saw in the book was the way to. as like the first space was to split. the second what to add a space in yet when i run it there all cluttered
Yes there is.

cout << tom<< " " << dick << " " <<harry << endl;
Topic archived. No new replies allowed.