Linux.com

Am I C-ing this right?

Link to this post 09 May 11

Hello.

I've just realised that all the headers mentioned in the Manpages are of style: something.h
From what I've been reading, I gather that they are all therefore C headers.

Am I correct?
If so, then what is the merit as an [exclusivley] Linux user in my learning C++?

Link to this post 09 May 11

The Linux kernel is written in assembly and C. Of course a lot of other software is written in C++ and other languages.

Java, C and C++ has been on the top of the index for a long time: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html so it's always good to learn.

Link to this post 09 May 11

Noluk wrote:

Hello.

I've just realised that all the headers mentioned in the Manpages are of style: something.h
From what I've been reading, I gather that they are all therefore C headers.

Am I correct?
If so, then what is the merit as an [exclusivley] Linux user in my learning C++?

I don't reallyl understand your question. Merit? Well, the learning itself! ;)

Usefulness? As a user... neither of them will be usefull for you. As a developer... depends ;)

Link to this post 09 May 11

The C++ language is based on, and backwards-compatible with, the C language. Programs written in C++ can be compiled against libraries written in C without any issues, and C code can be recompiled as a C++ program without adjustments. C++ however enables additional features like object-orientation, namespaces, operator overloading, streams and templates. In addition, it comes with more libraries like STL, the Standard Template Library.

So if you're learning to program, the basics of C and C++ should be quite similar (except the default way of handling input/output), but I would recommend that you at least familiarize yourself a bit with the features of C++. Even if you're writing purely procedural programs, the default programming paradigm of C, having features like streams and templates available can be quite neat. Having the Standard Template Library available also spares you the trouble of reimplementing common data structures and algorithms, e.g. binary search trees and sorting algorithms, every time you need them for a new datatype.

Link to this post 10 May 11

Noluk wrote:

Hello.

I've just realised that all the headers mentioned in the Manpages are of style: something.h
From what I've been reading, I gather that they are all therefore C headers.

Am I correct?
If so, then what is the merit as an [exclusivley] Linux user in my learning C++?

Well, maybe the kernel and most of the GNU utils were not written in C++, but plenty of the applications that run in most Linux distros - which make Linux useful - certainly are (Firefox, MySQL, LibreOffice, etc.).

Link to this post 10 May 11

For C++ headers, the .h is optional. You can have headers with, or without the .h for C++, but not for C. C requires the .h extension. So, in C++, you can do this:


#include <stdio.h> // A C header file
#include <iostream> // A C++ header
#include <stdlib.h> // A C, and/or C++ header

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board