A Developer’s Experiences with Constructors And Destructors In C++

The most compelling feature of C++ programming language is it being object oriented. An object is a fundamental aspect of an object oriented language like C++. The objects come from classes which is a collection of related type of information. As in C, we have structures as a user defined data-type, which is a collection of data members of different data-types. On Similar lines, C++ introduces the concept of classes, though with a lot of basic differences like the concept of constructors and destructors etc.

Let’s discuss a few differences here :

  • C structures just have data members, whereas C++ classes, apart from data members, can also have member functions.
  • C structure data members are all publicly accessible, however C++ classes have the power to specify access as private, public or even protected.
  • Another vital difference are constructors and destructors. To initialize objects, including dynamic memory allocation, implicitly in C++, programmers define constructors, and similarly, to destroy an object, including freeing the memory, it uses destructors. In this article, the we shall have an in-depth understanding of the C++ constructors and destructors.

[Note that, in the explanation above, we have discussed about C structures... C structures carry a lot of differences with C++ structures.]

In this article, we will discuss in detail the intricacies of constructors and destructors from a developer’s point of view.

(more…)

Linux strace command – A magnificent troubleshooter

Trying to run a program but facing weird errors? Well, most of the Linux users might have faced this situation. Many of us either spend hours searching on internet about the problem or wait for days on forums to get a reply. Sometimes we even give up and un-install the program. Very few of us know that there exists a Linux command line utility that can well be a good starting point for debugging these kind of problems. I am talking about the Linux strace command.
(more…)

Install and configure Ubuntu one

 

Ubuntu one is a cloud service offered by the canonical team. It’s the same team that works hard to improve Ubuntu year on year. The purpose of Ubuntu one is to have a centralized access to your stuff like Documents, music, pictures, contacts etc. The total free storage offered by default is 5GB and you can pay extra for more space if required. Here in this article, we will discuss the installation and configuration of Ubuntu one on Ubuntu 12.04 LTS.
(more…)

5 Linux wc command examples

The Linux wc command is a useful command that can come in handy if you ever want to know details like newline counts, byte counts, character counts etc for a file which is supplied as input. In this article, we will discuss 5 basic examples of this command.
(more…)

Get size related information of ELF files using Linux size command

If a Linux ELF executable is dissected, it can be disintegrated into different sections. What if you want to know the individual size of these sections and that too in various formats. Well, there is a Linux size command  that can do this for you. In this article, we will understand this command through some examples.
(more…)

Linux uname command

Want to know some details about your Linux system? Well, there is a command ‘uname’ that can tell you a lot about your Linux system. In this article, lets discuss Linux uname command through some examples.
(more…)

An example of buffer overflow in C using gets()

If you are new to C programming and use the library function gets() in your programs then its time that you stop and switch over to other alternatives. This is because the gets() function is not at all a safe function to use. Here in this article we will discuss buffer overflow in C using gets().
(more…)

Linux process that changes its own name

In one of our earlier articles, we learned how command line arguments are accessed from within the code. Here in this article, we will see how these command line arguments can be used by a Linux process to change its own name.
(more…)

Basics of GCC compilation process

In one of the earlier articles about Hello World C program on Linux , we learned how to write, compile and execute a basic C program on Linux platform in 3 easy steps. Among those 3 steps, the second step was to compile the source code to produce an executable file as output. In this article, we will try to go further deep into this compilation process to understand the basics of GCC compilation process by exploring what all happens behind the scenes when a source code is compiled to produce an output executable.
(more…)

© 2013 MyLinuxBook. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie
Close
Please support MyLinuxBook
Let your friends and followers know about MyLinuxBook

Twitter

Facebook

Google+