> multilis...">

"required from here" error declaring a list of lists

I am trying to declare a list of lists this way:

List_vector<List_vector<int> > multilist;

      

But Eclipse underlines the above declaration and gives this error:

required from here

Partial list_vector implementation:

template<class T>
class List_vector: public Linear_list<T, int> {
public:
  typedef typename Linear_list<T, int>::value_type value_type;
  typedef typename Linear_list<T, int>::position position;

  List_vector();
  List_vector(int);
  List_vector(const List_vector<T>&);
  ~List_vector();
private:
    void change_dimension_(T*&, int, int);
    value_type* elements_;
    int length_; // the length of the list
    int array_dimension_; // array dimension
};

      

Compiler output:

g++ -O3 -Wall -c -fmessage-length=0 -o multilista.o "..\\multilista.cpp" 
In file included from ..\multilista.cpp:1:0:
..\list_vector.h: In instantiation of 'List_vector<T>::~List_vector() [with T = List_vector<int>]':
..\multilista.cpp:16:32: required from here
..\list_vector.h:78:5: warning: deleting object of polymorphic class type List_vector<int>' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
..\list_vector.h: In member function 'List_vector<T>::value_type List_vector<T>::read(List_vector<T>::position) const [with T = int; List_vector<T>::value_type = int; List_vector<T>::position = int]':
..\list_vector.h:136:1: warning: control reaches end of non-void function [-Wreturn-type]
..\list_vector.h: In member function 'List_vector<T>::value_type List_vector<T>::read(List_vector<T>::position) const [with T = List_vector<int>; List_vector<T>::value_type = List_vector<int>; List_vector<T>::position = int]':
..\list_vector.h:136:1: warning: control reaches end of non-void function [-Wreturn-type]
g++ -O3 -Wall -c -fmessage-length=0 -o tester.o "..\\tester.cpp" 
g++ -o Lista.exe tester.o multilista.o 

      

+2


source to share


1 answer


In file included from ..\multilista.cpp:1:0:
..\list_vector.h: In instantiation of 'List_vector<T>::~List_vector() [with T = List_vector<int>]':
..\multilista.cpp:16:32:   required from here
..\list_vector.h:78:5: warning: deleting object of polymorphic class type 'List_vector<int>' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]

      

If you are going to extract from Linear_List

, you should consider making the destructor virtual as it says. This is only a warning, and only you know if it is really necessary (not enough code pasted on for judgment).

..\list_vector.h: In member function 'List_vector<T>::value_type List_vector<T>::read(List_vector<T>::position) const [with T = int; List_vector<T>::value_type = int; List_vector<T>::position = int]':
..\list_vector.h:136:1: warning: control reaches end of non-void function [-Wreturn-type]

      



You haven't pasted in the code for List_vector::read

, but it seems to be doing something wrong: every path from the function should return List_vector::value_type

(unless it throws an exception), but you allow control to reach the end without doing so.

..\list_vector.h: In member function 'List_vector<T>::value_type List_vector<T>::read(List_vector<T>::position) const [with T = List_vector<int>; List_vector<T>::value_type = List_vector<int>; List_vector<T>::position = int]':
..\list_vector.h:136:1: warning: control reaches end of non-void function [-Wreturn-type]

      

+1


source







All Articles