After I include Array.cpp in the main program, it works. But why? I don't remember in the previous exercise I have to do this.
It's magic, not allowed to say Just kidding.
Seriously, Array is a template (remember my videos?) and must #include "Array.cpp" otherwise compiler cannot find source code. Somewhere <T> needs to be replaced by <double> it does need Array.cpp the compiler phase (linker phase is too late).
The 13 Golden Rules of Debugging
1. Understand the requirements
2. Make it fail
3. Simplify the test case
4. Read the right error message
5. Check the plug
6. Separate facts from interpretation
7. Divide and conquer
8. Match the tool to the bug
9. One change at a time
10. Keep an audit trail
11. Get a fresh view
12. If you didn’t fix it, it ain’t fixed
13. Cover your bugfix with a regression test
This is a good one, i.e. can we reproduce the error at will? If not, get ready for sleepness nights
Occasionally hardware itself goes bad. The floating-point flaw in the 1994 Pentium processor that caused certain computations to produce wrong answers was a highly publicized and costly bug in the design of the hardware, but once it had been identified, it was of course reproducible. One of the strangest bugs we ever saw involved a calculator program, long ago on a two-processor system. Sometimes the expression 1/2 would print 0.5 and sometimes it would print some consistent but utterly wrong value like 0.7432; there was no pattern as to whether one got the right answer or the wrong one. The problem was eventually traced to a failure of the floating-point unit in one of the processors. As the calculator program was randomly executed on one processor or the other, answers were either correct or nonsense.