ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I came across this free C++ book (C++ and QT) that is apparently very good. I'm reading it right now. If you want to learn about C++ and QT at the same time (and going by the looks of it and the table of contents, a lot about both), this book is great: http://cartan.cas.suffolk.edu/oopdocbook/opensource/
As far as I can see, it misses two important aspects of C++ that are different from many other OOP languages and that you really should know about in order to write GOOD C++ code.
@zirias Well for me it's ok. I don't really follow standards or common philosophies on how C++ should be coded. I always use C++ to its fullest capability. I actually decide on how features of C++ should be used with a balance between speed or efficiency, and readability or design.
1.) if you DON'T understand the initialization concept of C++, you WILL run in unnecessary problems, for example with the creation of objects on the stack or with static initialization, and you start to code "workarounds" that aren't really needed and are inefficient.
2.) if you fail to provide a virtual destructor where it's needed, you risk memory leaks and similar bugs. if you provide one where it is not needed, you introduce inefficiency through an unneeded vtable.
So, I think it is very important to mention these things in any work trying to teach C++, at least in a later "advanced" chapter.
1.) if you DON'T understand the initialization concept of C++, you WILL run in unnecessary problems, for example with the creation of objects on the stack or with static initialization, and you start to code "workarounds" that aren't really needed and are inefficient.
I also debug C++ code. That really depends on the compiler and not really on the concept. No?
Quote:
2.) if you fail to provide a virtual destructor where it's needed, you risk memory leaks and similar bugs. if you provide one where it is not needed, you introduce inefficiency through an unneeded vtable.
Again that depends on the compiler.
Quote:
So, I think it is very important to mention these things in any work trying to teach C++, at least in a later "advanced" chapter.
I agree but I only need at least the ideal link for C++ and Qt4. The tutorial is quite enough for me. Optimizations will be done later. objdump can wait
Edit: I'm not implying that I don't use virtuals. In fact I even use them often. The only thing is that whatever it is that discussed in the tutorial, common philosophies of C++ for me won't matter to it.
And I think I have enough common sense for the things I need to use and the risks if I don't use them so I don't think I really have to follow standards.
Last edited by konsolebox; 07-07-2010 at 08:59 AM.
I also debug C++ code. That really depends on the compiler and not really on the concept. No?
There are a lot of issues related to member initialization where the compiler implementation has no choice when following the language standard. A typical example is a non-static member that has to be declared const for some reason. The only way to properly initialize ist, is in the member initialization list.
Of course, you don't really HAVE to understand the concept of coupling resource allocation to initialization that lead to this syntactical construct; it's probably enough to know that it's best to use it as much as possible -- but still you should (somehow) know about it in order to be a good C++ programmer.
Quote:
Again that depends on the compiler.
Maybe a compiler could chose to create a vtable even without virtual member functions -- that would be kind of a stupid implementation. The other way around, a good compiler could warn you about not using a virtual destructor where it is probably needed, but that would still be a guess
Quote:
And I think I have enough common sense for the things I need to use and the risks if I don't use them so I don't think I really have to follow standards.
Uhm, even if you chose to write some ISO-C89-style code and compile it with a C++ compiler, you still follow the standard
And if you're so sure you won't fall for these not-so-uncommon problems, it's ok, I still think a thread where a specific tutorial is recommended to anyone wanting to learn the language is a quite good place to give additional tips missing from the tutorial. I didn't say anything about all the topics actually covered in the tut, they're probably quite good.
There are a lot of issues related to member initialization where the compiler implementation has no choice when following the language standard. A typical example is a non-static member that has to be declared const for some reason. The only way to properly initialize ist, is in the member initialization list.
Of course, you don't really HAVE to understand the concept of coupling resource allocation to initialization that lead to this syntactical construct; it's probably enough to know that it's best to use it as much as possible -- but still you should (somehow) know about it in order to be a good C++ programmer.
Maybe a compiler could chose to create a vtable even without virtual member functions -- that would be kind of a stupid implementation. The other way around, a good compiler could warn you about not using a virtual destructor where it is probably needed, but that would still be a guess
Uhm, even if you chose to write some ISO-C89-style code and compile it with a C++ compiler, you still follow the standard
And if you're so sure you won't fall for these not-so-uncommon problems, it's ok, I still think a thread where a specific tutorial is recommended to anyone wanting to learn the language is a quite good place to give additional tips missing from the tutorial. I didn't say anything about all the topics actually covered in the tut, they're probably quite good.
Ok. I guess you're mostly right. That I'll mostly agree.
I've postponed reading that tutorial, actually.
I've decided to start with the official Qt book, found here: http://www.qtrac.eu/C++-GUI-Programm...t-4-1st-ed.zip
The other tutorial is good, but this is more of what I've personally been looking for.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.