Multiple Classes with a Text Editor

4 posts
by ac1dra1n » Wed Jul 10, 2013 3:02 pm
So I am using the Raspberry Pi to teach my self C++(I WILL get my $35 worth). A problem that I realize that I will run into soon is when I learn how to use multiple classes in a program. How would I go about making a multi-class program using the default text editor(Leafpad I think it is)? If using the text editor for a multi-class program isn't possible, should I get an IDE or learn how to use the terminal? If I need to get an IDE can anyone recommend a good one(preferably not Code Blocks because I've heard that is slow)? If I'm better off using the terminal, can anyone point me to a good tutorial on how to use it? Thanks in advance.
Posts: 16
Joined: Wed Feb 06, 2013 3:07 am
by Davespice » Wed Jul 10, 2013 3:11 pm
Geany isn't bad, or Eclipse if you want something more heavy weight.
User avatar
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 1586
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
by topguy » Fri Jul 12, 2013 3:12 pm
There is probably nothing in the c++ compiler that prevents you from writing many classes into a single source file.
But its not the correct way of doing it of course unless its really trivial classes. The nice thing to do is to have class1.h, class1.cpp and class2.h, class2.cpp.

Leafpad has no problems with letting you edit those files, one at the time. But if you want to switch quickly between each file, you either has to start multiple instances of leafpad or find an editor that supports multiple text-buffers. Geany is probably a good next step.

You also will have the problem of quickly compiling and linking many sourcefiles into a program, so you should also learn to write simple GNU Makefiles.
User avatar
Posts: 3011
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway
by technoducky » Wed Jul 17, 2013 11:06 am
Personally I use Code::Blocks, it is very easy to use especially for beginners.
It will also compile and link without a makefile (but you should still learn how to write them).

Usually though when I don't use Code::Blocks I just use vi/vim, which is also a good editor to learn to use.
Google Play Pi radio:
Posts: 62
Joined: Sat Jan 26, 2013 7:29 pm
Location: Newcastle, UK