Preventing class redefinition errors in C++

I have just started learning C++ and have been getting a lot of these errors. I finally found a solution to this after spending some time on the internet.

Say for instance you have a class called “Animal” and g++ complains that this class is being redefined. Just add the following two lines at the very top of the Animal.h file:

#ifndef ANIMAL_H
#define ANIMAL_H

and add the following at the very bottom of the file:


So, if your class is called SomeClass, then it will be SOMECLASS_H instead of ANIMAL_H. You should have these in every header file. It prevents that header file from being redefined more than once.

How to tell which Linux partition a directory is on?

This is really simple. First of all, you need to know the full path to that directory. “cd” into that directory and type:

and it will display full path of the directory you are in. Remember that or even better, copy it to the clipboard. Type the following command to know the name of the partition:

where replace with the full path of your directory. This in my case becomes “df /data/android/sample“.

If you are already in the directory, you can type “df .” and it will give details about the partition you are currently on.

The output should be something like:

The highlighted part is the name of your partition.

Pizza Ordering System source (Session 2)

Hey Guys! Thanks for watching my video. In case you haven’t, the video is down below:

I hope the video as helpful to you. Please comment below the video or this post for any suggestions/queries. You can download the source code by following the link below:

Job Execution API v0.1b is now available!

I have been working on this for a while and now I have finally released it. This is 0.1 beta so it may contain bugs. However, I am working on it constantly and am trying to improve the API.

Job Execution API is all about job execution in Java. You have jobs which comprise of tasks. Each task is a class implementing the ITask interface. For now, the task is not Async so tasks are executed sequentially, in linear pattern. I intend to provide basic tasks which you can use to create standard jobs. You can later extend these tasks and make your own.

Download the API here and let me know how it goes:

API for recognizing gestures in Android

I have been busy lately. For most of the time, I have been working on gesture API for android. Android already has a built in gesture API but to actually use it, you have to apply mathematics which makes it a bit comlicated for a normal Android developer. AGAPI (Accelerometer Gesture API) adds a layer of abstraction over the existing gesture API to make it easier to recognize gestures. Using AGAPI is very simple. Implement the ShakeListener or any gesture listener class. Register your listener to ShakeManager or corresponding gesture manager instance. Write your code in OnShake or in corresponding event methods and BAM! Your gesture rich application is ready! At this stage of development, the Shake gesture is ready to use. You can get the API here.

Note: This API is licensed under Apache License 2.0.