Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class std::vector<No> has no member named 'getId'
- #include <iostream>
- using namespace std;
- int main()
- {
- return 0;
- }
- #ifndef NO_H_INCLUDED
- #define NO_H_INCLUDED
- #include <vector>
- #include "Aresta.h"
- using namespace std;
- class No{
- private:
- int id;
- vector<Aresta> *adjNo;
- public:
- No(int id);
- int getId();
- vector<Aresta>* getAdjNo();
- void inserirAdj(Aresta aresta);
- int totalAdjacencias();
- };
- #endif // NO_H_INCLUDED
- #include "No.h"
- #include <vector>
- No::No(int id){
- this->id=id;
- this->adjNo = new vector<Aresta>;
- }
- int No::getId(){
- return this->id;
- }
- vector<Aresta>* No::getAdjNo(){
- return this->adjNo;
- }
- void No::inserirAdj(Aresta aresta){
- adjNo->push_back(aresta);
- }
- int No::totalAdjacencias(){
- this->adjNo->size();
- }
- #ifndef ARESTA_H_INCLUDED
- #define ARESTA_H_INCLUDED
- class Aresta{
- private:
- int id;
- int peso;
- public:
- Aresta(int id, int peso);
- int getId();
- };
- #endif // ARESTA_H_INCLUDED
- #include "Aresta.h"
- Aresta::Aresta(int id, int peso){
- this->id=id;
- this->peso=peso;
- }
- int Aresta::getId(){
- return this->id;
- }
- #ifndef GRAFO_H_INCLUDED
- #define GRAFO_H_INCLUDED
- #include "No.h"
- using namespace std;
- class Grafo{
- private:
- vector<No> *listNos;
- public:
- Grafo();
- void addNo(int id);
- bool existeNo(int id);
- };
- #endif // GRAFO_H_INCLUDED
- #include "Grafo.h"
- #include <iostream>
- Grafo::Grafo(){
- listNos = new vector<No>;
- }
- void Grafo::addNo(int id){
- if(!existeNo(id)){
- No noAux(id);
- listNos->push_back(noAux);
- } else
- cout << "No ja existe no Grafo";
- }
- bool Grafo::existeNo(int id){
- for(int i=0; i < listNos->size(); i++){
- if(listNos[i].getId() == id)
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement