0

I am trying to learn C++, although I've watched Bucky's tuts on Youtube... I think it would be better to learn in context (by actually creating an app that I can use & would like to use) so I'm taking baby steps towards my ideal blogging app. I'm starting by trying to write a really basic "writing app" (Basically a text editor) where the UI is really minimalistic and I just have a screen to write on & to format the text. (a Mac app)

Eventually I plan to add features like a pin board of research (on the blog post), link collection (for citing), Image sourcing? from your own Flickr, iPhoto and Instagram, posting to blogging services and sharing on social media platforms etc.

I've tried XCode and Qt (Both are great for creating an interface) but I want to actually write the code not have an app do it for me... so I am actually learning C++.

How would you do that? (Assuming you don't use an interface builder) By just writing code??? (I'm not sure how to do that, could you please show an example?)

Is there a process people go through? e.g. plan & outline write for the functions call the functions... & if statements.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Caffae
  • 13
  • 4
  • Writing a UI library is a pretty tough job. I think you would find it very difficult if you don't at least have experience with using and an in-depth understanding of an existing library first. – Joseph Mansfield Dec 23 '13 at 18:33
  • For starters, it might be helpful to look into [Unified Modeling Language](http://en.wikipedia.org/wiki/Unified_Modeling_Language) and the [MVC Framework](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) to have a well thought out design. – C.B. Dec 23 '13 at 18:34
  • 2
    The whole point of having an app do it for you is to avoid all the boiler-plate code that one would normally write (which is tedious and error-prone.) What better way to design how your application looks than actually creating it in the UI editor? –  Dec 23 '13 at 18:34
  • I'm not focusing on the app... This project is mainly so I can learn C++ properly, so though having an app do it for me would be much easier... that won't help me with my main purpose and if the app doesn't have the option of adding what I want then I won't know what to do. – Caffae Dec 23 '13 at 18:38

4 Answers4

1

GUI programming is a terrible way to learn C++ in my opinion. GUI programming in generally has very few tough algorithmic problems to solve. It's mostly just handling callbacks and setting listeners. Most of it comes down to layout, visual appeal and User experience. If you decided to create something with Qt you're basically going to be writing custom containers and defining various callbacks (Signals & Slots) to handle.

Here's a basic example widget definition from Qt docs: http://qt-project.org/doc/qt-5.0/qtwidgets/widgets-analogclock.html

class AnalogClock : public QWidget {
    Q_OBJECT

public:
    AnalogClock(QWidget *parent = 0);

protected:
    void paintEvent(QPaintEvent *event);
};
en4bz
  • 1,092
  • 14
  • 18
  • Okay, do you have a better suggestion to learn C++? Most of the books I see seem to be pretty outdated and online tutorials (e.g. Bucky's) don't really show me how to code an app (that's what I'm learning C++ for... so -.-'' ) – Caffae Dec 23 '13 at 18:55
  • @Caffae C++ isn't really an "App" language. It's mainly for systems programming, high performance computing and libraries. In terms of application programming C/C++ are mostly used together with Qt and other frameworks. Windows has mostly moved to C# for application programming although you can still use C++ its discouraged. If you want to do mobile Java (Android) and Obj-C (iOS) are king. C++ is also used heavily in games (Graphics) where you need very fast performance but even then its only used for rendering and game engines. – en4bz Dec 23 '13 at 19:09
1

I have learned C/C++ coding simple programs to read files (text and binary files) and after a little while, coding some visual stuff with [allegro][1] and other image frameworks (SDL, HGL, SexyApp Framework).

But it really doesn't matter what you are going to code when learning - you need to have passion for it. If you like to hack something, research and do the hacking. If you really want to do an app with a GUI, so do it. You are right to sit down and put your hands to work on a code, that's the best way to learn.

Getting back to your question: most of those frameworks creates all those code for you, just to get thins simpler. For instance I HATE to generate that kind of code by my own hands. But if you want to do it, you could use a portable lib like WxWidgets. Even with Qt you can go the hard way and create things by your own hands with their API.

After you choose your library, the most important thing is that you need to specify what you want to do. Get some papers and take notes of the features, do the dialog drawings (mockups or wireframes), and try to imagine what you will need to code for each feature, button and other actions.

After that planning, I recommend you to do things divided in parts (but always thinking on the whole thing) and code each feature separately (and try to keep it that way).

Learning C/C++ is not easy, but when you start to get things done, it's one of the best things that you can do while using clothes.

y3i12
  • 21
  • 3
0

Use an IDE, strongly suggest visual studio

http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx

or you can use g++ if you are in a linux environment

http://gcc.gnu.org/

JoeC
  • 1,850
  • 14
  • 12
0

It depends upon which operating system and which compiler are you using. I invite you to use Linux with a recent GCC 4.8 compiler (invoked as g++).

So first start to code a single-source C++ file (doing some "command-line" processing, e.g. computing the frequencies of words in some raw text file). Use the C++11 dialect (see cplusplus.com & cppreference.com ....). You'll edit it with an editor (like emacs, gedit, vim or geany etc....). Let's suppose it is somesource.cc.

(I don't recommend using an IDE for editing; it just hide things to you; the compiler is always command-line...)

Then compile it with

 g++ -Wall -g -std=c++11 somesource.cc -o someprog

Order of program arguments to g++ is important. You could use clang++ instead of g++ if you have it.

Learn to use the gdb debugger.

Later, you'll want to work on a many source-files application (perhaps using a library or framework like Qt). You'll need to learn how to use a builder like gnu make, see this, and a version control system like git.

I strongly recommend looking inside existing free software applications source code (and compiling them, perhaps improving them). See freecode or sourceforge or github to find one....

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547