CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 15 of 43

Thread: Namespace and stdafx.h

Threaded View

  1. #1
    Xeon's Avatar
    Xeon is offline Want me to ban you?! Power Poster
    Join Date
    Jul 2000

    Namespace and stdafx.h

    Hi all,

    I'm using Visual C++ 6.0 and reading from a very new C++ book written in 2005.

    Below is my code from the book :
    #include <iostream.h>
    #include <stdafx.h>
    using namespace std;
    int main()
    	cout << "Never fear, C++ is here!" << endl;
    	cout << "Do you C++?" << endl;
    	cout << "I'm back!\n";
    	cout << "I love real women!\n";
    	return 0;
    However, the compile gave me an error :

    C:\C++\Test\Test.cpp(3) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory

    Obviously, if I remove "#include <stdafx.h>" and "using namespace std;", the error disappears, but what I like to know if why this error appeared in the 1st place. How can there be no "stdafx.h" file in Visual C++? Also, "using namespace std;" is a valid statement, right?
    (I know the program can run without these 2 lines, though)

    Is it because Visual C++ 6.0 is too old?

    Last edited by Xeon; November 1st, 2005 at 10:05 AM.
    "Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria

    "I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)