Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. class std::vector<No> has no member named 'getId'
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. return 0;
  10. }
  11.  
  12. #ifndef NO_H_INCLUDED
  13. #define NO_H_INCLUDED
  14.  
  15. #include <vector>
  16. #include "Aresta.h"
  17.  
  18. using namespace std;
  19.  
  20. class No{
  21. private:
  22. int id;
  23. vector<Aresta> *adjNo;
  24. public:
  25. No(int id);
  26. int getId();
  27. vector<Aresta>* getAdjNo();
  28. void inserirAdj(Aresta aresta);
  29. int totalAdjacencias();
  30. };
  31.  
  32. #endif // NO_H_INCLUDED
  33.  
  34. #include "No.h"
  35. #include <vector>
  36.  
  37. No::No(int id){
  38. this->id=id;
  39. this->adjNo = new vector<Aresta>;
  40. }
  41.  
  42. int No::getId(){
  43. return this->id;
  44. }
  45.  
  46. vector<Aresta>* No::getAdjNo(){
  47. return this->adjNo;
  48. }
  49.  
  50. void No::inserirAdj(Aresta aresta){
  51. adjNo->push_back(aresta);
  52. }
  53.  
  54. int No::totalAdjacencias(){
  55. this->adjNo->size();
  56. }
  57.  
  58. #ifndef ARESTA_H_INCLUDED
  59. #define ARESTA_H_INCLUDED
  60.  
  61. class Aresta{
  62. private:
  63. int id;
  64. int peso;
  65.  
  66. public:
  67. Aresta(int id, int peso);
  68. int getId();
  69. };
  70.  
  71. #endif // ARESTA_H_INCLUDED
  72.  
  73. #include "Aresta.h"
  74.  
  75. Aresta::Aresta(int id, int peso){
  76. this->id=id;
  77. this->peso=peso;
  78. }
  79.  
  80. int Aresta::getId(){
  81. return this->id;
  82. }
  83.  
  84. #ifndef GRAFO_H_INCLUDED
  85. #define GRAFO_H_INCLUDED
  86.  
  87. #include "No.h"
  88.  
  89. using namespace std;
  90.  
  91. class Grafo{
  92. private:
  93. vector<No> *listNos;
  94. public:
  95. Grafo();
  96. void addNo(int id);
  97. bool existeNo(int id);
  98. };
  99.  
  100. #endif // GRAFO_H_INCLUDED
  101.  
  102. #include "Grafo.h"
  103. #include <iostream>
  104.  
  105. Grafo::Grafo(){
  106. listNos = new vector<No>;
  107. }
  108.  
  109. void Grafo::addNo(int id){
  110. if(!existeNo(id)){
  111. No noAux(id);
  112. listNos->push_back(noAux);
  113. } else
  114. cout << "No ja existe no Grafo";
  115. }
  116.  
  117. bool Grafo::existeNo(int id){
  118. for(int i=0; i < listNos->size(); i++){
  119. if(listNos[i].getId() == id)
  120. return true;
  121. }
  122. return false;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement