help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple program does not compile with g++-4.3 but with g++-4.2


From: Thomas Maeder
Subject: Re: simple program does not compile with g++-4.3 but with g++-4.2
Date: Fri, 21 Aug 2009 17:09:18 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)

Emanoil Kotsev <deloptes@yahoo.com> writes:

> 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";


reply via email to

[Prev in Thread] Current Thread [Next in Thread]