Hi,
I am currently working in a project. I have a function bitcount(int); in one one project file lets say "a.cpp" and i have a header "a.h" where i have defined that function. That function simply finds out the number of bits in a number. Now, I have another file "b.h" and "b.cpp". In "b.cpp" i need to call that function again. I tried few steps like including "a.h" in either "b.h" or "b.cpp" but I got errors. May be i am doing it a wrong way? Any suggestions? Here is what i did.
"a.h"
#ifndef A_H
#define A_H
class AX : public FU{
..
..
public:
int bitcount(int);
...
..
};
#endif
"a.cpp"
#include "a.h"
..
..
int X = bitcount(9);
cout << X;
int AX::bitcount(int x){
...
...
return bit_count;
}
"b.h"
# All includes
class BX: public FU{
private:
..
..
public:
..
..
};
#endif
"b.cpp'
#include "b.h"
...
..
Y = bitcount(200); // How to perform this operation?
cout << Y;
Sorry, I did not understand what you mean. Actually, what i am doing is the simulation project. Simulation is defined inside "main.cpp" where I have included all the headers. I am using an Eclipse for the project.
This sample program works fine but mine does not work somehow. In my case, i have another files "b.h' and "b.cpp" and i tried to call display(); from "b.cpp". So I just tried to create an object in "b.cpp" for "a" but i got error message. My "b.cpp" looks loke this:
#include "a.h"
void X::FU()
{
int x, y;
a anObject;
anObject.display(200);
}