i m a beginner in this language.. i was making code which can perform interconversion of binary, decimal, Octal and hexadecimal numbers. i have made all 16 programs bt i m having a problem in compiling them to 1 single program.. So can any one plz help me n show me if they have made such program so i can change mine accordingly...
how to manage C++ program
Collapse
X
-
Tags: None
-
What you are going to want to do is seperate all your functions into .h and .cpp files. The .h files are going to contain your declarations for your functions and the .cpp files are going to contain the definitions. So if you have a header file called Decimal.h
int decimalToBinary (int decimal); //this would go in your .h file
And in the .cpp file called Decimal.cpp you would have
#include "Decimal.h"
int decimalToBinary (int decimal)
{
<-- logic goes here
}
Now to reference this in your main all you need to do is include the .h file like this
#include "Decimal.h"
You also will want to take a look at include guards to prevent double inclusion or using #pragma once. #pragma once is non-standard so it might not work depending upon which compilier you are using.
Comment