list has not been declared

Asked

Viewed 167 times

1

I’m doing the first part of a c++ work on codeblocks and Ubuntu and I’m getting the following errors:

1 - 'list' has not been declared
2 - no matching Function for call to 'No::verifieNo(int&, Std:list&)'

There is include in the headers and I don’t understand what this second error might be.

No.h:

#ifndef NO_H
#define NO_H
#include <list>

class No{
    int id; //id do nó

    public:
    No(int);
    bool verificaExisteNo(int id, list &listNos);
};

#endif // NO_H

No cpp.:

#include "No.h"
#include <list>
#include <iostream>

using namespace std;

No::No(int id){
    this->id=id;
}

bool No::verificaExisteNo(int id,list &listNos){
    //para teste sempre retorno true;
    return true;
}

Main:

#include <iostream>
#include <stdlib.h>
#include <list>
#include "No.h"

using namespace std;

int main()
{
    int opcao,id1;
    No *noAux;

    list<No> listNos;
    list<No> listAdj;
    list<No>::iterator it;

    do{
    cout << "Trabalho de Teoria dos Grafos - 2016.1 - Eduardo Machado Lopes - 201465583A\n\nEscolha uma opcao para comecar:\n0 - Carregar arquivo do grafo."
        "\n1 - Incluir no.\n2 - Excluir no.\n3 - Incluir aresta.\n4 - Remover aresta.\n5 - Consultar no do grau.\n6 - Verifica k-regularidade.\n"
        "7 - Verifica se e completo.\n8 - Verifica se sao adjacentes.\n9 - Verifica se e conexo.\n10 - Verifica se pertencem a mesma componente conexa.\n"
        "11 - Verifica se e articulacao.\n12 - Verifica se e ponte.\n13 - Exibir lista de nos.\n14 - Exibir arestas.\n15 - Sair.\n\nEscolha: ";
    cin >> opcao;
    system("clear");
        switch (opcao){
            case 0:
                cout << "Em construcao.\n";
            break;
            case 1:
                cout << "Informe o nó que deseja inserir: ";
                cin >> id1;
                //Primeiro verifico se ele existe;
                if(noAux->verificaExisteNo(id1,listNos))
                    cout << "Existe nó";
                else
                    cout << "No existe nó";
            break;
            case 2:
                cout << "Em construcao.\n";
            break;
            case 3:cout << "Em construcao.\n";
            break;
            case 4:
                cout << "Em construcao.\n";
            break;
            case 5:
                cout << "Em construcao.\n";
            break;
            case 6:
                cout << "Em construcao.\n";
            break;
            case 7:
                cout << "Em construcao.\n";
            break;
            case 8:
                cout << "Em construcao.\n";
            break;
            case 9:
                cout << "Em construcao.\n";
            break;
            case 10:
                cout << "Em construcao.\n";
            break;
            case 11:
                cout << "Em construcao.\n";
            break;
            case 12:
                cout << "Em construcao.\n";
            break;
            case 13:
                cout << "Em construcao.\n";
            break;
            case 14:
                cout << "Em construcao.\n";
            break;
        }
        cout << endl;
    } while (opcao!=15);
    return 0;
}

Thank you anyway!

1 answer

0


You forgot to put the namespace in No.h. And in the archives No.h and No.cpp you must define the type of the list list<No>

#ifndef NO_H
#define NO_H
#include <list>

using namespace std;

class No{
    int id; //id do nó

    public:
    No(int);
    bool verificaExisteNo(int id, list<No> listNos);
};

#endif // NO_H

Without the namespace you can declare the list with the std::list:

bool verificaExisteNo(int id, std::list<No> listNos);
  • Thanks for the reply Brumazzi, but now the error that is appearing is: 'list' is not a type...

  • has to send the change you made to get to that mistake?

  • I put as another answer to be able to maintain the identation @Brumazzi DB...

  • @Dudulopes made a change in response, see if it now works, on my pc it worked

  • It worked! I need to edit the title for solved?

  • no, just having the v marked already indicates that your problem has been solved

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.