From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1064 invoked by alias); 5 Mar 2003 23:33:49 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 1046 invoked from network); 5 Mar 2003 23:33:48 -0000 Received: from unknown (HELO main.gmane.org) (80.91.224.249) by 172.16.49.205 with SMTP; 5 Mar 2003 23:33:48 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 18qiNx-0003jw-00 for ; Thu, 06 Mar 2003 00:33:17 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-help@gcc.gnu.org Received: from news by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 18qiNw-0003jn-00 for ; Thu, 06 Mar 2003 00:33:16 +0100 From: Oscar Fuentes Subject: Re: Problems getting g++ to run Date: Wed, 05 Mar 2003 23:33:00 -0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@main.gmane.org User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 X-SW-Source: 2003-03/txt/msg00057.txt.bz2 "Karl Gangle" writes: > Hi, > > I am trying to compile a c++ program using g++ in Linux. The program is > > #include > #include > > int main() { > > string s1( "string1" ); > > cout << s1 << endl; > > return 1; > } > > > The compiler errors indicate that string, cout, endl, and s1 are not > defined. And, indeed, they are not. All those identifiers are inside std namespace, like all other C++ Standard Library names, so just prepend them with std:: #include #include int main() { std::string s1( "string1" ); std::cout << s1 << std::endl; return 1; } If you don't want to type lots of std::'s, you can use this too, although is considered a bad practice by lots of gurus: #include #include using namespace std; int main() { string s1( "string1" ); cout << s1 << endl; return 1; } [snip] -- Oscar