Dev - C++ - [Error] ISO C++ forbids comparison between

 
Vista:
sin imagen de perfil
Val: 2
Ha disminuido su posición en 5 puestos en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

[Error] ISO C++ forbids comparison between

Publicado por juan (2 intervenciones) el 04/10/2019 15:26:05
Hola buenas a todos... tengo este archivo.cpp y me arrojan 3 errores que estan al final del texto y no se que hacer...les agredeceria mucho si me ayudan


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
#include <iostream>
#include <string>
 
using namespace std;
 
 
class Marticulo
{
 
private:
 
	int cantidad;
char tipo_articulo;
 
	public:
		Marticulo();
 
		void settipo_articulo(char tp);
		void setcantidad(int cn);
 
 
		int getcantidad();
		char gettipo_articulo();
 
		float calcularArticulo();
};
 
 
Marticulo::Marticulo(){}
 
void Marticulo::setcantidad(int cn)
{cantidad = cn;}
 
int Marticulo::getcantidad()
{ return cantidad;}
 
void Marticulo::settipo_articulo(char tp)
{ tipo_articulo = tp;}
 
char Marticulo::gettipo_articulo()
{ return tipo_articulo;}
 
 
float Marticulo::calcularArticulo()
{
 
char tipo_articulo;
float x;
 
if (tipo_articulo == "C")
x = (100*0.30)-cantidad;
else if(tipo_articulo == "B")
x = (100*0.50)-cantidad;
else if(tipo_articulo == "S")
x = (100*0.20)-cantidad;
 
return x;
 
 
 
}
 
 
linea 52/ 	[Error] ISO C++ forbids comparison between pointer and integer [-fpermissive]
linea 54/  [Error] ISO C++ forbids comparison between pointer and integer [-fpermissive]
linea 56   [Error] ISO C++ forbids comparison between pointer and integer [-fpermissive]
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
Imágen de perfil de Alfil
Val: 4.344
Oro
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

[Error] ISO C++ forbids comparison between

Publicado por Alfil (1444 intervenciones) el 04/10/2019 18:24:54
Tienes que cambiar las dobles comillas (un string) por comillas simples (un char)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
float Marticulo::calcularArticulo()
{
    char tipo_articulo;
    float x;
 
    if( tipo_articulo == 'C' )
        x = ( 100 * 0.30 ) - cantidad;
    else if( tipo_articulo == 'B' )
        x = ( 100 * 0.50 ) - cantidad;
    else if( tipo_articulo == 'S' )
        x = ( 100 * 0.20 ) - cantidad;
 
    return x;
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar