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

Threaded View

  1. #1
    Xeon's Avatar
    Xeon is offline Want me to ban you?! Power Poster
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    4,195

    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 :
    Code:
    #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?

    Thanks!
    Xeon.
    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
  •  





Click Here to Expand Forum to Full Width

Featured