There is a declaration of template class with implicit parameters:
List.h
template <typename Item, const bool attribute = true>
class List: public OList <item, attribute>
{
public:
List() : OList<Item, attribute> () {}
....
};
I tried to use the fllowing forward declaration in a different header file:
Analysis.h
template <typename T, const bool attribute = true>
class List;
But G++ shows this error:
List.h:28: error: redefinition of default argument for `bool attribute'
Analysis.h:43: error: original definition appeared here
If I use the forward declaration without implicit parameters
template <typename T, const bool attribute>
class List;
compiler does not accept this construction
Analysis.h
void function (List <Object> *list)
{
}
and shows the following error (i.e. does not accept the implicit value):
Analysis.h:55: error: wrong number of template arguments (1, should be 2)
Analysis.h:44: error: provided for `template<class T, bool destructable> struct List'
Analysis.h:55: error: ISO C++ forbids declaration of `list' with no type
Updated question:
I removed the default parameter from the template definition:
List.h
template <typename Item, const bool attribute>
class List: public OList <item, attribute>
{
public:
List() : OList<Item, attribute> () {}
....
};
The first file using class List has forward declaration with implicit value of the parameter attribute
Analysis1.h
template <typename T, const bool attribute = true>
class List; //OK
class Analysis1
{
void function(List <Object> *list); //OK
};
The second class using class List WITH forward definition using the implicit value
Analysis2.h
template <typename T, const bool attribute = true> // Redefinition of default argument for `bool attribute'
class List;
class Analysis2
{
void function(List <Object> *list); //OK
};
The second class using class List WITHOUT forward definition using the implicit value
Analysis2.h
template <typename T, const bool attribute> // OK
class List;
class Analysis2
{
void function(List <Object> *list); //Wrong number of template arguments (1, should be 2)
};