I would really want some advanced C++ programmer to answer me this question, so please help me I really need this answer.
How can I really start programming with C++? Of course, I still have a lot to lean.

I just learned classes and SOME of inheritance features, I write some simple programs, but I don't see the way how to write some nice code that will be useful ( it doesn't have to contain GUI, right? ).

I don't think it's possible that I don't have an inspiration. What programs did you make after learning these things and can you recommend me what I should write with knowledge of these features?

I would appreciate any answer :icon_cheesygrin: thanks in advance

Try something you'd personally find useful, such as a CD/DVD cataloging application. Since you want to program in C++ (my favorite language - been using it for 20 years), try to "think objectively". Think about the things you are modeling, and write the classes for those things with the behavior they should have. Each class should have its own header file and source file - don't jam everything together in one huge source file. That just makes modifications and bug fixes more difficult.

Make sure your class constructors properly initialize all member variables that do not have constructors of their own.

Avoid the NIH (Not Invented Here) syndrome - use standard library functions as much as possible. They have been thoroughly tested, and trust me when I say that writing your own vector or string classes may be educational, you will spend a lot of time implementing something that isn't as good, fast, or efficient.

Passing arguments to functions, where in C you would use a pointer, use a reference instead. It will eliminate an entire class of bugs when you try to dereference a null pointer. The compiler will catch that stuff for you.

Always declare destructors as virtual, and always have a destructor, even if it does nothing. Some day you will want to use that class as a base class, or have it derived from some other class, and this will enable you to delete pointers to either base or derived and it will do the right thing. If you don't, and you have a pointer to the base part and delete that object, the derived part won't be properly destroyed. So as much as possible, declare and implement a default constructor, copy constructor, destructor, and assignment operator. IE:

class MyClass {
private:
    int m_IntVar;
    float m_FloatVar;
public:
    MyClass() : m_Intvar(0), m_FloatVar(0.0) {}
    MyClass( const MyClass& cpy ) : m_Intvar(cpy.m_IntVar),
                                    m_FloatVar(cpy.m_FloatVar) {}
    virtual ~MyClass() {}
    MyClass& operator=( const MyClass& rhs )
        { m_IntVar = rhs.m_IntVar; m_FloatVar = rhs.m_FloatVar; return *this; }
};

As shown, use the initialization block for member variable initialization. Don't push that into the body of the constructor unless absolutely necessary. That will happen from time to time when you need to deal with exceptional conditions, but that should be pretty rare.

There are some good C++ programming books out there which you should invest in. You can find a lot of them on Amazon.com, including used volumes at significant discounts. Anyway, good luck!

>>What programs did you make after learning these things and can you recommend me what I should write with knowledge of these features?

Some of my early programs, while at your level, mostly revolved around 3D graphics (simple 2D/3D computer games, simple physics engines, collision detection algorithms, procedural generation of landscapes and other natural artifacts, particle systems, dynamics simulator and editor, etc.). The best project for you is the project YOU are most interested in (I'm a math junky so that drove the type of programs I played around with, and still work on today).

It's always difficult to keep yourself focused when you are doing programs as a hobby (not for money or a university degree, or both). To maximize your chances of not getting bored or burnt out, you should first make sure you have a good interest in the field (that drives the "impress yourself" reward-system), and second, try to pick a project that is very incremental and implement it incrementally so that you see new results every step of the way (it also eases the debugging/testing process a lot!). Another thing that can boost your focus and engage you more into the project is to do it with others, with friends and/or through an open-source team-project.

Following a level of knowledge in C++ that makes you feel confident enough to move from "textbook example" kind-of code towards a more concrete project, I think the natural next step is to learn to use other libraries and off-the-shelf tools and APIs. For most kinds of projects, whichever you pick, there will be opportunity to use off-the-shelf tools and libraries, it could be a GUI tool (like Qt), a 2D/3D graphics tool (like OpenGL/GLUT/GLUI and/or SDL), an image or video streaming library (like OpenCV, VTK, ITK, gstreamer, etc.), a database tool (like MySQL), network libraries, etc., etc. Try to use popular tools that have plenty of tutorial examples and online resources, they can help a lot to at least get things working even if you are lost in the complexity of the library (which is normal at first). It also has the benefit of exposing you to other people's code, for better or worse, in any case, you will learn a lot from it (either by going "Wow that's a cool/simple/easy way to do it!" or by going "Humm, I wonder why they implemented this that way.. maybe I should look into it..").

When you have a good idea of the project(s) you want to work on, then it might start to grow in size, and then you will need further knowledge in two areas: software engineering (as in high-level design of your software, class hierarchies and so on), and "C++ Coding Standards" (which is also the title of a must-have book in C++, by Sutter and Alexandrescu). The former is useful to make better choices in creating your software, and the latter will be necessary to improve the quality of the code which directly, positively affects the effectiveness of your coding. Another benefit of implementing things incrementally is that you will face challenges incrementally, and you will learn a bit more on those two aspects every time you meet a challenge.

thanks guys , this helps a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.