error when compiling main c ++ file


There is an error that has come up to me several times, I have modified the classes to remove that error, but it keeps coming out when executing the main, I do not know what it is referring to, we appreciate help.

this is the main code:

#include "muro.hpp"

using namespace std;

int main(void){

    int altura=0;
    int anchotodoelmuro=0;
    cout<< "Introduzca el ancho total del muro que desea construir  "<<endl;
    cout<< "Introduzca la altura del muro que desea construir  "<<endl;

    vectorfila r(anchotodoelmuro);
    muro d(altura,anchotodoelmuro);


this is the declaration of the wall class:

#include "vectorfila.hpp"
//Aquí creo los distintos muros posibles
using namespace std;

    class muro{
            //error comun:  error no matching function: cuando sale esto, mala declaracion de estructuras de datos
            int alto_;
            //hay dos estructuras de vectores aqui, un vector dentro de otro puse vectorbloque filastotales investigar
            //no necesito valoresfila, con filastotales[i].size() recorro una fila hasta la ultima posicion
            // vectoresbloques hace referencia a un muro
            vectoresbloques filamurooptimo;
            typedef vector<vectoresbloques> mposibles;
            mposibles murosoptimos;
            mposibles muroscompletos; //preguntar declarar en otra funcion
            muro(int alto,int anchototal);

I think the problem is with the constructors and how to link class, as I found in some old posts here, but I do not know how to correct it. Errors when compiling:

C:AppData\Local\Temp\ccssZ0oq.o main_muro.cpp:(.text+0x99): undefined reference to 'vectorfila::vectorfila(int)'

C:AppData\Local\Temp\ccssZ0oq.o main_muro.cpp:(.text+0xae): undefined reference to 'muro::muro(int, int)'

C:\AppData\Local\Temp\ccssZ0oq.o    main_muro.cpp:(.text+0x99): undefined reference to 'vectorfila::vectorfila(int)'
C:\AppData\Local\Temp\ccssZ0oq.o    main_muro.cpp:(.text+0xae): undefined reference to 'muro::muro(int, int)'
C:\AppData\Local\Temp\ccssZ0oq.o    main_muro.cpp:(.text+0xba): undefined reference to 'muro::~muro()'
C:\AppData\Local\Temp\ccssZ0oq.o    main_muro.cpp:(.text+0xc6): undefined reference to 'vectorfila::~vectorfila()'
C:ALIEN\AppData\Local\Temp\ccssZ0oq.o   main_muro.cpp:(.text+0xdc): undefined reference to 'vectorfila::~vectorfila()'
F:  [Error] ld returned 1 exit status

Help is appreciated. Thanks

asked by AER 27.09.2017 в 01:27

1 answer


I see that you have not declared class vectorfila r(anchotodoelmuro); only class muro also in class muro , I see that you declare a vetor of type vectoresbloques but I do not see where you have defined that class, typedef vector<vectoresbloques> mposibles; .

answered by 27.09.2017 / 17:03