Good morning, good afternoon and good evenings (to cover almost all posibilities)

The error message is as follows in DEV-C++ compiler

Compiler: Default compiler
Building Makefile: "I:\cpp\Makefile.win"
Executing make...
make.exe -f "I:\cpp\Makefile.win" all
g++.exe include/Test.o include/Objeto.o include/ConjuntoBase.o include/IteradorBase.o include/ConjVector.o -o "TestEstructurasDiscretas.exe" -L"C:/Dev-Cpp/lib"
include/ConjVector.o(.text+0x45):ConjVector.cpp: undefined reference to `vtable for ConjVector'
include/ConjVector.o(.text+0x4b):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x59):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x129):ConjVector.cpp: undefined reference to `vtable for ConjVector'
include/ConjVector.o(.text+0x12f):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x13d):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x20d):ConjVector.cpp: undefined reference to `vtable for ConjVector'
include/ConjVector.o(.text+0x213):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x21e):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x229):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x341):ConjVector.cpp: undefined reference to `vtable for ConjVector'
include/ConjVector.o(.text+0x347):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x352):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x35d):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x475):ConjVector.cpp: undefined reference to `vtable for ConjVector'
include/ConjVector.o(.text+0x47b):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x484):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x493):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x567):ConjVector.cpp: undefined reference to `vtable for ConjVector'
include/ConjVector.o(.text+0x56d):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x576):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x585):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x80d):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x812):ConjVector.cpp: undefined reference to `ConjVector::enMemoria'
include/ConjVector.o(.text+0x81c):ConjVector.cpp: more undefined references to `ConjVector::enMemoria' follow
collect2: ld returned 1 exit status
make.exe: *** [TestEstructurasDiscretas.exe] Error 1
Execution terminated

the problem is somewhere in tht ConjVect.cpp class that implement ConjVect.h the code in both files is
"ConjVector.h"

/* ConjVector.h */
#ifndef _CONJVECT_H_
#define _CONJVECT_H_
#include "ConjuntoBase.h"

class ConjVector:public ConjuntoBase{

private:
 
  static int enMemoria;
 
  static int longitudEnMemoria(const int&);
        
  Objeto** elementos;
  int      longitud;

protected:
  virtual void vaciar();
  
  virtual void quitar(const Objeto&);

  virtual void agregar(const Objeto&);
  
public:
       
  static int longitudEnMemoria();
       
  ConjVector(const Objeto**,int);
  
  ConjVector(const Objeto&);
  
  ConjVector();
  
  virtual int cardinal() const;
  
  virtual IteradorBase* enumerar() const;
  
  virtual ~ConjVector();   
  
  friend class ItVector;
  
};
#endif

ConjVector.cpp

#include "ConjVector.h"
#include "IteradorBase.h"

class ItVector:public IteradorBase{
private:
  const ConjVector* soporte;
  mutable int actual;
public:
  ItVector(const ConjVector& c):soporte(&c){
    actual = 0;
  }
  
  ItVector(const ItVector& i):soporte(i.soporte){
    actual = i.actual;
  }
  
  virtual bool masElementos()const{
    if(soporte!=NULL){
      return (actual<soporte->cardinal());
    }return false;
  }
  
  virtual const Objeto& siguiente()const{
    Objeto* o = soporte->elementos[actual];
    actual++;
    return *o;
  } 
  
  virtual bool igual(const Objeto& o) const{
    if(typeid(o) == typeid(*this)  || typeid(o).before(typeid(*this))){
      const ItVector& copia = dynamic_cast<const ItVector&>(o);
      return (copia.soporte == soporte && copia.actual == actual);
    }else return false;
  }
  
  virtual ItVector* clonar() const{
    return new ItVector(*this);
  }
  
  virtual ItVector* crear() const{
    return new ItVector(*(this->soporte));
  }
  
};

ConjVector::ConjVector(){
  if(ConjVector::enMemoria>0){
    elementos = new Objeto*[ConjVector::enMemoria];
    longitud = 0;
  }else{
    elementos = NULL;
    longitud = 0;
  }
}

ConjVector::ConjVector(const Objeto** v,int l){
  if(ConjVector::ConjVector::enMemoria==0) ConjVector::enMemoria = l;
  elementos = new Objeto*[ConjVector::enMemoria];
  longitud = l;
  for(int i=0;i<l;i++){
    elementos[i] = v[i]->clonar();
  }
}

ConjVector::ConjVector(const Objeto& o){
  if(ConjVector::ConjVector::enMemoria==0) ConjVector::ConjVector::enMemoria = 1;
  elementos = new Objeto*[ConjVector::enMemoria];
  longitud = 1;
  elementos[0] = o.clonar();
}

void ConjVector::agregar(const Objeto& o){
  if(longitud==longitudEnMemoria()){
    Objeto** nuevo = new Objeto*[longitudEnMemoria(longitudEnMemoria()+(longitudEnMemoria()/2))];
    for(int i = 0;i<=cardinal();i++){
      nuevo[i] = elementos[i];
    }  
    delete elementos;
    elementos = nuevo;
  }
  elementos[longitud] = o.clonar();
  longitud++;
}

void ConjVector::quitar(const Objeto& o){
  int i = 0;
  bool encontrado = false;
  while(i<cardinal() && !encontrado){
    encontrado = elementos[i]->igual(o);
    i++;
  }
  if(encontrado){
    i--;
    delete elementos[i];
    longitud--;
  }
}

int ConjVector::cardinal()const{
  return longitud;
}


IteradorBase* ConjVector::enumerar()const{
  return new ItVector(*this);
}


int ConjVector::longitudEnMemoria(const int& i){
  ConjVector::enMemoria = i;
  return ConjVector::enMemoria;
}


int ConjVector::longitudEnMemoria(){
  return ConjVector::enMemoria;
}

Can anyone explainme why it is not recognizing the declaration

static int enMemoria;

or give me a clue on what i'm doing wrong
Thaks a lot in advance.
Regards

The declaration only is not enough, so ...

// in ConjVector.cpp

// initialize enMemoria to some value ...
int ConjVector::enMemoria = 0;

Thaks it solved that problem. Now i'm getting the following error message

[Linker error] undefined reference to `vtable for ConjVector'

I got this error before when I was trying to compile a derived class but didn't have all calsses added to the project. That time I solved the problem. Now I have not a clue.
May you help me again

Thaks it solved that problem. Now i'm getting the following error message
[Linker error] undefined reference to `vtable for ConjVector'

You have one or more virtual methods declared but not implemented in the class.

Thanks a lot, again!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.