• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

simple c++ question regarding #include

EmperorNero

Golden Member
here is a simple programming example in Object Oriented Programming in C++ by Robert Lafore (just notice the first 4 lines):

#include <iostream>
using namespace std;
#include <conio.h> // for getche()

int main()
{
int number;

number = getche();

if (number > 10)
cout << &quot;Number is greater than 10;&quot;;

return 0;
}

how come #include <iostream> (without the .h) is legal while I have to include the .h in #include <conio.h>? If I exclude the .h from conio.h, VC++ would say there is no such file.
 
My guess is since that &quot;iostream&quot; is a very common used library it's possible to write it without the &quot;.h&quot; since it assumes it's &quot;.h&quot;.

The other &quot;conio.h&quot; might not be a standard library (I haven't heard about it) and therefore you need to write the full filename.
 
iostream is actually a different version of iostream.h. That is why it uses that &quot;namespace std&quot; command also.

There are a lot of libraries for VC++ that don't have extensions, these are part of the same package as the STL (standard template library). I don't know of any way in which the std libraries work different than iostream.h.
 
Back
Top