However, it gives the errors when I compile: variable "dim1" is not a type name and for variable "dim2" it complains about a duplicate parameter name. Any solutions?
The declarations of dim1 and dim2 should stay in myCommon.h. They can also be defined in myCommon.cpp if needed, but can't go into test.h.
I think you should put some include guards in that "myCommon.h" file of yours.
Is your question related to IO?
Read this C++ FAQ LITE article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
What is that code supposed to do when you place it in the class declaration? That line of code belongs in a function.
The bottom line is this:
When you create a header file, you're supposed to #include anything it needs to compile successfully without any "help" from outside. For example, this one line CPP file must compile without error:
Code:
#include "test.h"
Try to compile that one line of code. If it doesn't compile, you go into test.h and fix the errors.
Bookmarks