list has not been declared

1

I'm doing the first part of a c ++ job in codeblocks and ubuntu and am getting the following errors:

  

1 - 'list' has not been declared
  2 - no matching function for call   to 'No :: checkExistNo (int & std :: list &)'

There is the include in the headers and I did not understand what that 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!

    
asked by anonymous 17.04.2016 / 00:35

1 answer

0

You forgot to set namespace to No.h . And in the files No.h and No.cpp you should set the type of 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 namespace you can declare list with std::list :

bool verificaExisteNo(int id, std::list<No> listNos);
    
17.04.2016 / 01:32