LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 01-23-2008, 09:30 PM   #1
ejoftiduttu
LQ Newbie
 
Registered: Oct 2007
Posts: 8

Rep: Reputation: 0
Error while compiling C++ Program


I just tried the simple pgrogram below
#include<iostream>

int main()
{
cout<<"Hello World!\n";
return 0;
}
BUT IT SHOWED AN ERROR LIKE THIS . Is it bcoz it dont hav glibc headers?

[dinesh@SHADOWMAN Cpp]$ g++ 1.cpp
1.cpp: In function ‘int main()’:
1.cpp:5: error: ‘cout’ was not declared in this scope
 
Old 01-23-2008, 09:43 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 60
Code:
#include<iostream>

int main()
{
  std::cout << "Hello, world!\n";
  return 0;
}
or
Code:
#include<iostream>
using namespace std;

int main()
{
  cout << "Hello, world!\n";
  return 0;
}
Read on namespaces in C++.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in compiling Postgres FE C program skie_knite007 Programming 2 03-16-2007 11:38 PM
error compiling srgp program in c csst0136 Programming 10 10-25-2005 01:14 AM
error compiling srgp program in c csst0136 Suse/Novell 0 10-23-2005 03:46 PM
error while compiling c /c++ program kiranbud Programming 1 10-12-2005 09:19 PM
error compiling a program minm Linux - Newbie 7 08-01-2005 11:40 AM


All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration