PDA

Click to See Complete Forum and Search --> : old version of c++


PT Exorcist
Dec 2nd, 2002, 06:05 AM
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?

CornedBee
Dec 2nd, 2002, 06:28 AM
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:

template<typename T>
inline void initStruct(T &s) {
ZeroMemory(&s, sizeof(T));
s.dwSize = sizeof(T);
}


which would be really useful for DirectDraw programming...

parksie
Dec 2nd, 2002, 08:19 AM
Can't it? :eek:

I would have expected even VC6 to be able to do that. Yikes; no wonder Ked did so much whining :D

CornedBee
Dec 2nd, 2002, 11:09 AM
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...

PT Exorcist
Dec 8th, 2002, 07:19 PM
where can i download vc6 new version?

CornedBee
Dec 9th, 2002, 01:41 AM
"Nowhere".

If you get my meaning...

PT Exorcist
Dec 9th, 2002, 06:11 AM
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 :\

CornedBee
Dec 9th, 2002, 06:44 AM
Show me that code. I can't imagine a Hello-World app not working in any VC++.

PT Exorcist
Dec 9th, 2002, 03:06 PM
// lolololol.cpp : Defines the entry point for the console application.
//

#include "iostream"
using namespace std;

int main()
{
cout << "C++ is power programming";

return 0;
}

PT Exorcist
Dec 9th, 2002, 03:08 PM
ah forgot the error :D:
c:\program files\microsoft visual studio\myprojects\lolololol\lolololol.cpp(14) : fatal error C1010: unexpected end of file while looking for precompiled header directive

HairyDave
Dec 9th, 2002, 03:13 PM
You have made the project with precompiled headers. This means that you MUST include


#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

Zaei
Dec 9th, 2002, 03:49 PM
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.

HairyDave
Dec 9th, 2002, 03:52 PM
Originally posted by Zaei
It doesnt have to be the first line. However, any lines preceding it are simply ignored.


:rolleyes: Yeah, which is why it finds the end of file while looking for it.

HD

PT Exorcist
Dec 9th, 2002, 04:09 PM
but that's how it is in the book :(

PT Exorcist
Dec 9th, 2002, 04:13 PM
k now working lol

CornedBee
Dec 9th, 2002, 05:39 PM
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.