I recommend running it through the preprocessor only (-E with GCC), and you should find something like this:
Code:
namespace 1{
template <class type, int n> class vector;
and
Code:
class State : public 1::vector<double, 4> { };
Use a convention for macro names that doesn't let them get mixed up with other identifiers (e.g macro names and only macro names are ALL CAPS).
-----------
Another thing:
Code:
template <class type, int n>
bool checkSize(const vector<type, n>& v1, const vector<type, n>& v2)
{
try {
if( v1.size != v2.size )
throw "Operations of two vectors of not the same size!";
return true;
}
catch( char * str ) {
std::cout << "Exception raised: " << str << std::endl;
}
}
1) Don't use throw for flow control inside a function. Exceptions are thrown to indicate to the caller that something is wrong, otherwise you can just use normal flow control constructs:
Code:
template <class type, int n>
bool checkSize(const vector<type, n>& v1, const vector<type, n>& v2)
{
if( v1.size == v2.size )
return true;
std::cout << "Exception raised: Operations of two vectors of not the same size!" << std::endl;
//note the lack of return statement!?: did you mean: return false;?
}
2) Printing an error message and continuing as if nothing happened (in this case returning an indeterminate value) is not a particularly good error handling strategy. The caller will not know what happened in checkSize.
3) If you need to throw exceptions, prefer throwing exception objects (preferable one defined in <stdexcept> or derived from those) over built-in types.