PDA

View Full Version : Learning C++



iampriteshdesai
July 22nd, 2008, 02:28 PM
I am new and learning C++. Which software to use? How do I start compiling.

Potatoj316
July 22nd, 2008, 02:40 PM
in the terminal type

sudo aptitude install build-essential
the c++ complier is called g++, to compile your code you type (terminal again)

g++ NAME.cpp
(i think thats all you need, there might be a switch you need to use) you can also put a -o then the name of the output file (that part is optional) check out g++ --help for more info (or man g++)

your code can be written using any pain-text text editor. (vim, emacs, gedit, nano...)

dracayr
July 22nd, 2008, 02:51 PM
its plain-text editor not pain text editor ;)

dracayr

Archimedes0212
July 22nd, 2008, 02:55 PM
I like using emacs for writing or even gedit. Both highlight the code which is the main thing I look for. I compile and run from the terminal with g++.

Potatoj316
July 22nd, 2008, 02:58 PM
I think vim highlights or maybe gvim as well.

Oh, and dracayr is too picky. Maybe I was talking about a text editor that hurts to use, its to discourage people from programing.

dracayr
July 22nd, 2008, 03:08 PM
Maybe I was talking about a text editor that hurts to use, its to discourage people from programing.


everything is possible : take a look at MS's 'editor' (I think that was the name, it's a standard program in Window$):D

dracayr

stump138
July 22nd, 2008, 03:10 PM
I've been using geany alot lately for writing editing code and makefiles, then running make in a terminal.

KIAaze
July 22nd, 2008, 03:27 PM
Here's a nice exhaustive list of software:
List of Free Software and Freeware IDEs (http://www.linuxquestions.org/questions/programming-9/list-of-free-software-and-freeware-ides-469623/)
(But don't start with an IDE right away if you're just beginning. It actually makes things more complex sometimes. ^^)

As for C++ tutorials, I don't know any reference site, but google should know.

SteveNorman
July 22nd, 2008, 03:37 PM
I like the matching parenthesis feature in VIM..also the line numbering. I use vim or gedit (which can also be set to line number). save the text as whatever.cpp, where whatever is the name of the program you are making.

in a terminal just do:


g++ whatever.cpp -o whatever

to compile....

and do:


./whatever

...to run

here is a good tutorial:

http://www.cplusplus.com/doc/tutorial/

iampriteshdesai
July 22nd, 2008, 03:41 PM
iS There any GUI for G++? Rather than staring at terminal any thing with optins like menu> edit, compile?

lamego
July 22nd, 2008, 04:02 PM
Try code::blocks, you can get it from http://www.getdeb.net/app/code::blocks .

Sef
July 22nd, 2008, 04:13 PM
Moved to programing talk.

era86
July 22nd, 2008, 04:39 PM
Try code::blocks, you can get it from http://www.getdeb.net/app/code::blocks .

+1

Anjuta also has the compile/project feature.

KIAaze
July 22nd, 2008, 05:03 PM
iS There any GUI for G++? Rather than staring at terminal any thing with optins like menu> edit, compile?

I think you're looking for an IDE (Integrated Development Environment (http://en.wikipedia.org/wiki/Integrated_development_environment)).
That's what the list I gave you earlier is for.
(also contains Anjuta & Code::Blocks ;) )

Most IDEs (those available for GNU/Linux anyway) use gcc and g++ as compilers, so one could say that they're a "compiler GUI", altough they do much more than that, like giving auto-completion, syntax highlighting, package building, etc.
They also offer a GUI for debugging tools like gdb and valgrind.

StOoZ
July 22nd, 2008, 05:24 PM
I would suggest on using netbeans (use google to search it).
:guitar:

nvteighen
July 22nd, 2008, 05:45 PM
I suggest you not to go for a IDE and learn what's going on when you compile a program.

If you want to learn C++, you've better be prepared to know the internal of things... Afterwards, you can leave something automate things, but if for some reason the IDE doesn't work (more usual than you think), you'll be able to fix it by yourself. When using a compiled lower-level language, you have to be independent and know how stuff work.

If you want to have something simple that doesn't need know how to compile, go for Python or any other higher-level interpreted language. There's nothing bad at them.

"Compiled" doesn't mean "superior", just "compiled".

LaRoza
July 22nd, 2008, 06:13 PM
See the sticky.