Dev - C++ - [ERROR] no match for 'operator==' (operand types are 'Nodo' and 'Long long int')

 
Vista:

[ERROR] no match for 'operator==' (operand types are 'Nodo' and 'Long long int')

Publicado por jhonmTomax (1 intervención) el 07/02/2023 04:23:06
Este Es un ejercicio de la universidad en el que tengo que hacer un menu con diferentes cosas pero me sale el siguiente error

[ERROR] no match for 'operator==' (operand types are 'Nodo' and 'Long long int')

en la linea 114 del codigo,estoy intentando hacerlo a ver si consigo el problema pero aun nada, si podrian ayudarme en ya termina el ejercicio lo agradeceria un monton

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include <string>
#include <vector>
#include <iostream>
#include <memory>
 
using namespace std;
class Nodo
{
 
 //Declaración de atributos
 private:
 int dato = 0;
 Nodo *siguiente;
 int n;
 //Constructores de la clase Nodo
 public:
 Nodo(int dato, Nodo *siguiente);
 Nodo(int datos);
 
 
 //Metodos getter and setter
 virtual int getDato();
 
 virtual void setDato(int dato);
 
  virtual Nodo getSiguiente();
 
 virtual void setSiguiente(Nodo *siguiente);
};
class Lista
{
 
 public:
 Nodo inicio;
 Nodo fin;
 
 public:
 lista();
 
 virtual void agregarFin(int info);
 
 virtual void imprimir();
 
 virtual void eliminar(int valor);
};
 
 
class Principal
{
 
 public:
 static int leerEntero(const std::wstring &linea);
 
 static void main(std::vector<std::wstring> &args);
};
 
//Main function added by Java to C++ Converter:
 
#include <string>
#include <vector>
 
int main(int argc, char **argv)
{
	std::vector<std::wstring> args(argv + 1, argv + argc);
	Principal::main(args);
}
 
//.cpp file code:
 
 
Nodo::Nodo(int dato, Nodo *siguiente)
{
 this->dato = dato;
 
 this->siguiente = siguiente;
}
 
Nodo::Nodo(int datos)
{
 this->dato = datos;
 this->siguiente = NULL;
}
 
int Nodo::getDato()
{
 return dato;
}
 
void Nodo::setDato(int dato)
{
 this->dato = dato;
}
 
Nodo Nodo::getSiguiente()
{
return *siguiente;
}
 
void Nodo::setSiguiente(Nodo *siguiente)
{
 this->siguiente = siguiente;
}
 
Lista::lista()
{
 inicio = fin = NULL;
}
 
void Lista::agregarFin(int info)
{
 
 Nodo nuevo = Nodo(info, NULL);
 
 if (inicio == 	NULL)
 {
  inicio = fin = nuevo;
 }
 else
 {
  fin->setSiguiente(nuevo);
  fin = nuevo;
 }
 
}
 
void Lista::imprimir()
{
 Nodo aux = inicio;
 while (aux != nullptr)
 {
  cout << aux->getDato() <<endl;
  aux = aux->getSiguiente();
 }
}
 
void Lista::eliminar(int valor)
{
 Nodo anterior = inicio;
 Nodo aux = inicio->getSiguiente();
 Nodo temp;
 while (aux != nullptr)
 {
  //Condicional simple para eliminacion de nodos
  if (aux->getDato() > valor)
  {
   temp = aux->getSiguiente();
   anterior->setSiguiente(aux->getSiguiente());
   aux = temp;
  }
  else
  {
   anterior = anterior->getSiguiente();
   aux = aux->getSiguiente();
  }
 }
}
using Scanner = java::util::Scanner;
 
int Principal::leerEntero(const std::wstring &linea)
{
 Scanner leer = Scanner(System::in);
 cout << linea << std::endl;
 int dato = leer->nextInt();
 return dato;
}
 
void Principal::main(std::vector<std::wstring> &args)
{
 Lista coleccion =Lista();
 int opcion;
 cout << L"EJERCICIO 3 - LISTAS SIMPLES ENLAZADAS\n" <<endl;
 do
 {
 cout << L"MENU PRINCIPAL:" <<endl;
 cout << L"1.- Ingresar datos a la lista" <<endl;
 cout << L"2.- Imprimir Lista" <<endl;
 cout << L"3.- Eliminar datos que se pasan de un limite." <<endl;
 cout << L"4.- Salir" <<endl;
  opcion = leerEntero(L"Seleccione una opción:");
 
  switch (opcion)
  {
  case 1:
  {
   int nuevo = leerEntero(L"Ingrese el elemento que desee ingresar a la lista:");
   coleccion->agregarFin(nuevo);
   break;
  }
  case 2:
  {
   cout << "La lista ingresada es:" <<endl;
   coleccion->imprimir();
   break;
  }
  case 3:
  {
   int valor = leerEntero(L"Ingrese el valor que sirva de limite:");
   coleccion->eliminar(valor);
   break;
  }
  case 4:
  {
   cout << "FIN DEL PROGRAMA" <<endl;
   break;
  }
  }
 }while (opcion != 4);
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder