today's leftovers


-
Header Guards C++
A header guard in C++ is a component that proves to be your savior whenever you attempt and make a mistake while writing your code by defining a function more than once with the same name. Every programmer needs to know that it is never considered good practice to include the function definitions in the header files. However, at times, you need to do so. In that case, you must know how to properly use the header guards in C++. Therefore, this article discusses the need to use the header guards in C++, followed by some examples to teach you their usage on the Ubuntu 20.04 system.
Why Do We Need to Use the Header Guards in C++?
While writing your code, you define certain header files on your own, depending upon the functionality you require. After creating these header files, you can include them all in your .cpp file that contains your actual code. However, sometimes these header files depend upon each other. So, you have to include one header file into another. In that case, when you include both these header files into your .cpp file, the same functions of one header file might be defined twice. This leads to the generation of a compile-time error since C++ strictly prohibits the definition of the same function twice within the same code. Therefore, we use the header guards to protect your header files from malfunctioning to resolve this dependency issue.
These header guards can be implemented using the four pre-processor directives: #ifndef, #define, #ifdef, and #endif. For example, whenever you enclose a piece of code within the “#ifndef” directive, the compiler always checks whether the following code has been previously defined or not. If not, then the statements following the “#define” directive are executed. Otherwise, these statements are simply ignored. This, in turn, ensures that your program always compiles successfully and the same functions are not defined more than once within the same code. The “#ifdef” directive works vice-versa. You will be able to understand all this in a better way after going through the following two examples.
-
2021 in review: 'Right to Repair' campaigners claim iPhone victory
Manufacturers, including Apple, are still introducing new features that appear intended only to make repairs more difficult, says Kevin Purdy at iFixit, a company that sells spare parts and offers free how-to guides. Components that are glued together or require proprietary tools to remove are common and can often be overcome using third-party kits from such services, but a growing trend is for companies to add software-coded serial numbers to components, which alert the device to any unauthorised repairs.
-
New year, new Opensource.com community manager | Opensource.com
I am privileged to be here at Opensource.com as the new community manager. I'm looking forward to working with existing correspondents and contributors, and also bringing in new contributors and increasing the diversity of thoughts and ideas shared here on Opensource.com.
-
Best Ubuntu Themes In 2022
Ubuntu is one of the most popular Linux operating systems right now on the internet. It is often considered as the first choice for people using Linux for the first time.
In this post, we will be discussing the best Ubuntu themes available on the internet. You can install various Ubuntu themes to make your distro more beautiful.
-
Noodlings 35 | Light for Christmas
-
Happy New Year, Folks — Let's Fill it with Linux, Yeah?! - OMG! Ubuntu!
This is a short (and yes, rather predictable) post to wish every single person reading this site a very merry—wait, we’ve already had that one—a happy new year.
Yes, even those of you still sat in your pants (the British kind).
It may feel like the world now exists in a dark timeline but there are things to be hopeful about, especially where Linux and open source software is concerned.
After all, despite the environment, 2021 was a particularly buoyant year for Ubuntu on the desktop
Ubuntu 21.04 and 21.10 both made their way out with new features, new kernels, and in the latter’s case, even a new desktop. Strong foundations laid ahead of April 2022 release of Ubuntu 22.04 LTS.
-

- Login or register to post comments
Printer-friendly version- 1968 reads
PDF version
More in Tux Machines
- Highlights
- Front Page
- Latest Headlines
- Archive
- Recent comments
- All-Time Popular Stories
- Hot Topics
- New Members
digiKam 7.7.0 is released
After three months of active maintenance and another bug triage, the digiKam team is proud to present version 7.7.0 of its open source digital photo manager. See below the list of most important features coming with this release.
|
Dilution and Misuse of the "Linux" Brand
|
Samsung, Red Hat to Work on Linux Drivers for Future Tech
The metaverse is expected to uproot system design as we know it, and Samsung is one of many hardware vendors re-imagining data center infrastructure in preparation for a parallel 3D world.
Samsung is working on new memory technologies that provide faster bandwidth inside hardware for data to travel between CPUs, storage and other computing resources. The company also announced it was partnering with Red Hat to ensure these technologies have Linux compatibility.
|
today's howtos
|








.svg_.png)
Content (where original) is available under CC-BY-SA, copyrighted by original author/s.

Recent comments
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago