This program works well. The the object of data type of class used to count something.
However, the compiler generated the error when I broke this program into 3 parts:
- The interface file, Problem5.h, contains the class definition.
- The implementation file, Problem5.cpp, contains the class's member functions, #include "Problem5.h" was written.
- The application file used to test above class, #include "Problem5.h" was written.
* When I compiled them, it was fine. However, when I ran them, it seemed to get trouble with the linker.
The weird thing is, the program works perfectly when I broke the program into 2 parts, the file contains the definiton of class and its member functions' definition, called Problem5.h; and the file contains the main() function.
Everyone can help me out please. Here is the code:
using namespace std;
CounterType(int number); //Constructor
void output(ostream& numberout);
// <---- interface file
cout<<"The first object that counts from 1-->10, except 3&7 :";
cout<<"The second object that is initilized with 100: "<<countvalue<<endl<<endl;
//<---- application (drive) file
CounterType::CounterType() : count(0)
cout<<"Count contains negative number. No negative number is allowed!\n\n";
if (count > 0)
void CounterType::output(ostream& numberout)
numberout << count;
//<----- implementation file