Results 1 to 16 of 16

Thread: old version of c++

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    old version of c++

    hi i am starting with c++ and i have a question

    in my book it says that c++ compilers made before of the standartization does not use the "using namespace std;" and that in the begginin of the file they put the extension of the #include like this: include <"iostream.h"> but that now it isnt need anymore...i have visual c++ 6.0 but it seems like an old compiler..anyone could explain me this?
    \m/\m/

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Visual C++ 6 is a new compiler using this measure. It understands the new
    #include <iostream>
    using namespace std;

    but it also understands
    #include <iostream.h>

    for backwards compability with older code. And unlike VC++7 or gcc 3.x it doesn't warn you about the fact that such code is outdated.
    Whenever you're writing new code use the new syntax.

    But VC++6 is old in other terms. First, there's a new version out. Second, it is really bad when it comes to templates. It can't even compile this simple code:
    Code:
    template<typename T>
    inline void initStruct(T &s) {
      ZeroMemory(&s, sizeof(T));
      s.dwSize = sizeof(T);
    }
    which would be really useful for DirectDraw programming...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Can't it?

    I would have expected even VC6 to be able to do that. Yikes; no wonder Ked did so much whining
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    VC++6 didn't compile it. The version of Borland I had compiled it, but got the sizeof wrong. A version of gcc we had in school (<3.0) did everything right...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    where can i download vc6 new version?
    \m/\m/

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    "Nowhere".

    If you get my meaning...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah when u said new version u meant vc++7?

    i bough a book about c++ (that says that supports vc++6) but i tryed to compile a bit of code saying hello world and it isn't workin :\
    \m/\m/

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Show me that code. I can't imagine a Hello-World app not working in any VC++.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Code:
    // lolololol.cpp : Defines the entry point for the console application.
    //
    
    #include "iostream"
    using namespace std;
    
    int main()
    {
    	cout << "C++ is power programming";
    
    	return 0;
    }
    \m/\m/

  10. #10

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah forgot the error :
    c:\program files\microsoft visual studio\myprojects\lolololol\lolololol.cpp(14) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    \m/\m/

  11. #11
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    You have made the project with precompiled headers. This means that you MUST include

    Code:
    #include "stdafx.h"
    Or whatever the precompiled header is as the first line of every .cpp file in the project. You can turn these off in the project settings.

    I think you'll need to replace "iostream" with <iostream>, but parksie or CB will be able to correct me if I'm wrong. Other than that its fine - just need to sort the precompiled header out.

    HD

  12. #12
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Originally posted by HairyDave
    Or whatever the precompiled header is as the first line of every .cpp file in the project. You can turn these off in the project settings.
    It doesnt have to be the first line. However, any lines preceding it are simply ignored.

    Z.

  13. #13
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    Originally posted by Zaei
    It doesnt have to be the first line. However, any lines preceding it are simply ignored.
    Yeah, which is why it finds the end of file while looking for it.

    HD

  14. #14

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    but that's how it is in the book
    \m/\m/

  15. #15

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    k now working lol
    \m/\m/

  16. #16
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Always create an "Empty Project", then you don't need to worry about precompiled headers.

    "iostream" is legal, but <iostream> should be preferred. <name> means the compiler should only look in the standard incldue directories, while "name" means it should look first in the current (or project) directories, then in the standard include directories. For standard headers you should use <name>: it avoids the problem of accidently having a header of the same name which would be preferred and lets other people easily find out which standard headers are included.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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