I wrote a very basic program but was not able to understand the behaviour of it.
# include<stdio.h>
# include<iostream.h>
# include<conio.h>
using namespace std;
int main()
{
cout << "50" << oct <<"50" << hex <<"50" << abc << "50";// error abc not defined
cout << "50" << oct <<"50" << hex <<"50"; // No error output 505050
getch();
}
Are oct and hex defined as some macro in any of the files that I have included which is the reason why I don’t get an error for second cout statement?
octandhexare stream manipulators defined in<ios>, whereas abc is not a symbol defined in any of the Standard header. Hence you see the error about only abc as you’ve not declared it yourself in your program.Apart from that it seems that you’re using very old compiler which comes with
<iostream.h>. I would suggest you to update your compiler (or switch to better compiler), and use<iostream>instead of<iostream.h>which is not Standard header.