I want to declare an array 'space' type 'ComponenteSpazio' to be 'static' because it contains lists and the 'free list' in the section 'private' of ListaCur <T>
the professor told me that the class 'Knot' must extend the virtual Linear_List, although 'ListaCur' extends well 'Linear_List'. Perhaps the problem is dependent on this?Or maybe I misunderstood me?
#ifndef _LISTALIN_H
#define _LISTALIN_H
#include <iostream>
using std::cout;
using std::endl;
using std::ostream;
// classe astratta listaLineare
template< class T, class P >
class Linear_list{
public:
typedef T value_type; // the type of object, T, stored in the list
typedef P position;
// operators
virtualvoid create() = 0;
// virtual bool empty() const = 0; // true if the list's size is 0
// virtual value_type read(position) const = 0;
// virtual void write(const value_type & x, position p) = 0; // write x at position p
// virtual position begin() const = 0; // returns a position pointing to the beginning of the list
// virtual bool end(position) const = 0; // returns a position pointing to the end of the list
// virtual position next(position) const = 0; // returns the next position
// virtual position previous(position) const = 0; // return the previous position
// virtual void insert(const value_type &, position) = 0; // insert an element
// virtual void erase(position pos) = 0; // ersaes the element at position pos
// virtual void clear()=0; // erases all the elements
// virtual int size() const = 0; // returns the size of the list
// virtual ~Linear_list() {};
};
/* sovraccarica <<. Attenzione se il tipo restituito da read non è primitivo, allora
* anche per questo tipo bisogna sovraccaricare l'operatore <<
*/
template< class T, class P >
ostream& operator<<(ostream& os, const Linear_list<T,P> &l){
typename Linear_list<T,P>::position p;
p = l.begin();
cout << "[";
while (!l.end(p)){
if (p != l.begin())
cout << ", " << l.read(p);
else
cout << l.read(p);
p = l.next(p);
}
cout << "]" << endl;
return os;
}
#endif // _LISTALIN_H
ListaCur<T>::typedef ComponenteSpazio<T> SPAZIO
Why did you add the typedef in the middle?
typename ListaCur<T>::ComponenteSpazio<T> *ListaCur<T>::SPAZIO = ListaCur<T>::inizializza();
ComponenteSpazio<T> is no part of ListaCur.
Replace it with SPAZIO, that's what the typedef is for typename ListaCur<T>::SPAZIO *ListaCur<T>::SPAZIO = ListaCur<T>::inizializza();
template<class T>
class ListaCur : public Linear_list<T, int>{
public:
...
private:
typedeftypename ListaCur<T>::ComponenteSpazio<T> SPAZIO; //10 errors
//[Error] expected unqualified-id before '<' token
Then I want to declare an array SPACE [100] cells or nodes, and its type is' Space Component <T> ', I realized then that typedef I do not need because I do not want to replace the type name ' Space Component ' with ' SPACE ' why ' SPACE ' is the name of the array you want to create. I tried with ComponenteSpazio <T> SPACE [MAXLUNG];
but errors increase.