How to use a defined class when several classes are defined in different files?
When I started, I am in different files in different files.
Then use the place where this class is used, and the result is analogously, very
Multiple errors. Later, I asked my colleagues, my colleague said that I want to put the statement of the class in a first text.
In the pieces, then implement it in the class file. When using it,
head File. I made a Demo as follows:
Suppose this demo has two classes: A, B, defined in classa.cpp and classb.cpp
In, there is a main.cpp, used to call A, B, two classes, a MyHeader.h,
To store a statement of A and B. The source code is as follows:
1.myHeader.h:
Class A
{
PUBLIC: A () {}
Void print ();
}
Class B
{
PUBLIC: B () {}
Void print ();
}
2.classa.cpp
#include
3.classb.cpp
#include
#include "myHeader.h" main () {a * a = new a (); b * b = new b (); A-> print (); b-> print (); return 0;} The execution result is as follows :