View Full Version : [ubuntu] C++ Compiler in Ubuntu 10.04 LTS
rshinde70
January 27th, 2011, 02:07 PM
Hi Friends..
I'm using Ubuntu 10.03LTS. Now days I've started learning C++.
But unfortunately, Only c codes can be compiled on This version of ubuntu while I'm not able to compile/run C++ codes.
is here anybody knows the right solution???
cgroza
January 27th, 2011, 02:09 PM
You need the G++ compiler. You can get it by:
sudo apt-get install build-essential
rshinde70
January 27th, 2011, 02:11 PM
You need the G++ compiler. You can get it by:
sudo apt-get install build-essential
It's already installed, :(
cgroza
January 27th, 2011, 02:13 PM
How about:
sudo apt-get install g++
You run it by:
g++ filename
rshinde70
January 27th, 2011, 02:22 PM
How about:
sudo apt-get install g++You run it by:
g++ filename
The same problem continues...
What gcc shows if i tries to comile like..
r
ohit@rohit-desktop:~$ sudo apt-get install g++
[sudo] password for rohit:
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++ is already the newest version.
g++ set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 234 not upgraded.
rohit@rohit-desktop:~$ vi trial.cpp
rohit@rohit-desktop:~$ g++ trial.cpp
trial.cpp:1:21: error: iostream.h: No such file or directory
trial.cpp: In function ‘int main()’:
trial.cpp:4: error: ‘cout’ was not declared in this scope
rohit@rohit-desktop:~$
cgroza
January 27th, 2011, 02:28 PM
Ok, from now it is just compile errors.
The include line should be:
#include <iostream> // standard library header files do not have .h extension.
And with the cout error, you could put a:
using namespace std;
or std:: right before the cout statement.
rshinde70
January 27th, 2011, 02:36 PM
Ok, from now it is just compile errors.
The include line should be:
#include <iostream> // standard library header files do not have .h extension.
And with the cout error, you could put a:
using namespace std;or std:: right before the cout statement.
Thanks Brother. I understood about that header file But i didn't understand about 'cout'
I really didn't understand. Could you explain it please?
cgroza
January 27th, 2011, 05:52 PM
It is because the cout function is present in the std namespace. The "cout::" or using namespace std introduces this new name in the current name space so you can use it.
Read a little bit about namespaces in C++ and you will understand. It basically groups things that have something in common.
EDIT: std:: does not introduce new names in the current namespace, but only accesses it from there.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.