error: aggregate '' has incomplete type and cannot be defined.

This is a discussion on error: aggregate '' has incomplete type and cannot be defined. within the C++ Programming forums, part of the General Programming Boards category; Help!!! I´m working in a project and when I try to compile I got plenty errors... one of them if ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    15

    error: aggregate '' has incomplete type and cannot be defined.

    Help!!! I´m working in a project and when I try to compile I got plenty errors... one of them if error: aggregate 'Parser parser' has incomplete type and cannot be defined.
    The code where appears it is:

    insert
    Code:
    class Parser;
    
    #ifndef CFUNCION_H
    #define CFUNCION_H
    
    #include "Parser.h"
    #include "CTermino.hpp"
    
    //using namespace std;
    
    class CFuncion: public CTermino {
    
    //.... stuff
    
      bool operator==( CTermino *ter2 )
        //Sobrecarga del operador "==" que define una relación entre dos términos,
        //la relación de IGUALDAD. Informalmente, dos terminos son IGUALES cuando cada uno de los simbolos
        //que componen al término los son. Es decir, viéndo los términos como cadenas, las cadenas deberán ser
        //exactamente iguales
        {
            bool ig = true;
             Parser parser;
            if (!ter2->perteneceVariable(ter2) && !parser.esConstante(ter2)){
    //Se que son funciones
    //Deberia castear a funcion para poder usar los metodos propios?
                    list<CTermino> * listTer1 = this->getListaParametros();
                    list<CTermino> * listTer2 = ter2->getListaParametros();
                    list<CTermino>::iterator it1 = listTer1->begin();
                    list<CTermino>::iterator it2 = listTer2->begin();
    
                    while ( ((it1 != listTer1->end()) || (it2 != listTer2->end())) && ig)
                    {
                    //Si tienen distinta cantidad de parametros, es decir, alguno llego al final antes que el otro
                    if (((it1 == listTer1->end()) && (it2 != listTer2->end())) ||
                        ((it1 != listTer1->end()) && (it2 == listTer2->end())))
                        ig = false;
                    else
                        ig = (*it1) == (*it2); //que pasa aca?? :S
                    //Aca estoy pidiendo equivalencia entre el componente de los terminos...
    
                    it1++; it2++;
                    }
                    delete listTer1;
                    delete listTer2;
                }
            else
                ig=false;
    
                return ig;
        }

    Could someone help me??? What is the reason of that error?? What should I do to correct it??
    Thanks in advance!!!

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    I don't suppose that Parser.h includes CFuncion.h?
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    15
    Yes... It´s something like a 'cross reference'... Parser needs CFuncion and then I want to use a method of Parser inside CFuncion... is that posible to do?

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    That's what is causing your problem. If you move the code to a .cpp file instead of putting everything in the header, that will put you on the right track. You can then get rid of the #include Parser.h from this header file.

    The general rule is: Never let 2 header files include each other.
    bit∙hub [bit-huhb] n. A source and destination for information.

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    15
    Thanks a lot!!!! That work out!!! I appreciate your help!!!! Thank you very much!!!

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21