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.
Just to illustrate that C++ does not add to the functionality of C, here is an alternative way of extending structs and functions when dealing with pointers (ie when base_func is prototyped as void base_func(struct base_struct *b);):
Yes, there's a reason it was named C++. The real added value is automation of all of the messiness involved with alignment of base classes (especially virtual,) management of virtual functions, and templates. Those are all things the compiler takes care of, making it less likely that you'll make an error. Admittedly, those aren't runtime features, but not having preventable bugs is a runtime feature. You could, of course, also use asm instead of C.
The real added value is automation of all of the messiness involved with alignment of base classes (especially virtual,) management of virtual functions, and templates.
That was pretty much my original point. This automatic class management reduces the scope for miscommunication between team members and makes it easier to adapt library classes to suit your needs.
Of course, a C programmer would not normally adopt an "everything is an object" mentality as above and would use more efficient coding mechanisms.
...
Of course, a C programmer would not normally adopt an "everything is an object" mentality as above and would use more efficient coding mechanisms.
C++ is pretty far from this mentality. Or, pretty close . In C++, according to the standard, in dumbed down form an object is a memory area. I am serious.
I rather prefer to see the world through everything is a function, and we sometimes need to store state paradigm.
Last edited by Sergei Steshenko; 07-06-2013 at 09:24 AM.
C++ is pretty far from this mentality. Or, pretty close .
C++ is a little more flexible in how you approach a programming task.
Of course, even purely OOP languages like Java don't force you to think purely in terms of objects. For example, you wouldn't consider the java.lang.Math class to be an object but a set of mathematical functions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.