I'm using debian stable. Thanks in advance
----- test code ----------
#include <iostream.h>
int main()
{
cout << "The size of an int is:\t\t" << sizeof(int) << " bytes
\n";
cout << "The size of a short int is:\t" << sizeof(short) << " bytes
\n";
cout << "The size of a long int is:\t" << sizeof(long) << " bytes
\n";
cout << "The size of a char is:\t\t" << sizeof(char) << " bytes
\n";
cout << "The size of a float is:\t\t" << sizeof(float) << " bytes
\n";
cout << "The size of a double is:\t" << sizeof(double) << " bytes
\n";
return 0;
}
----- test code ----------
> Hello, I'm trying to learn a bit more of c++. Unfortunately what was
> working in g++ 4.2 is not working in 4.3 anymore. Why?
The code you give below has never been valid since C++ was stadardized
11 years ago.
> I don't think I'm suppose to be changing my code because of this or
> knowing what somebody did change in the compiler. Perhaps I'm
> missing something like compatibility for 4.3.
You'll have to.
> #include <iostream.h>
This not a C++ header. Do
#include <iostream>
#include <ostream>
instead. <iostream> provides the object cout and <ostream> those
overloads of << which are not member functions.
> int main()
> {
> cout << "The size of an int is:\t\t" << sizeof(int) << " bytes \n";
Note that cout belongs to namespace std. You either have to add a
using directive or declaration, or (prefered by me), write
std::cout << "The size of an int is:\t\t" << sizeof(int) << " bytes\n";
thanks for explaining the issue. I've got this from a book called learn c++
in 21 days (as I already have a good experience in C and perl objects) it's
really not hard to progress
Well part of the question (or the main point was) why it's working in 4.2
and not in 4.3
thus suddenly it won't compile. To me it does not look like a change made 11
years ago but yesterday also I know the .h at the end is wrong but it's
compiling with 4.2.
I would like to be able to compile my code in the future that's all.
I don't like somebody to decide on behalf of me if I should port my code or
not. This is called integrity and compatibility and the present situation
is absolutely not reliable.
regards
> I don't like somebody to decide on behalf of me if I should port my code or
> not. This is called integrity and compatibility and the present situation
> is absolutely not reliable.
You are certainly free to write non portable code -- which may not
compile with newer versions of your compiler.
But that is exactly your problem here, isn't it?
Your example program is not ISO C++, it's ancient C++.
To compile ancient C++ you will have to stick with ancient compilers.
If you want to use current and future compilers, you must write ISO C+
+.
--
P.
all this is pretty clear, so the change has been done from 4.2 to 4.3
From your statement above I can conclude that 4.2 is ancient compiler and
4.3 is not ... which is funny.
I even remember to have read something about the .h files, when I was
installing 4.3, but not pretty sure. I think it was over two years ago.
so is g++-4.3 ISO C++ ? I'm just curious, because I would bet no.
And I still don't understand what's the problem with the old code ... if it
has been working in 4.2, why not make it work in 4.3 ... or somebody got
tired of making it work ... or it's even more complicated. In the latter
case I don't want to know - yes/no is fine.
thanks in advance - the ISO C++ was good one. So I need a book about iso c++
in 21 days :-D
regards