Programación General > C/C++
ERROR INEXPLICABLE
Hypocrisy:
Hola...ya estoy de nuevo aqui...Al compilar un programa me sale un constante error que no consigo quitar. Se que el programa esta bien pero igualmente sale el maldito error.
El error que sale es el siguiente: :hitcomp: :hitcomp:
expected unqualified-id before "namespace"
expected `,' or `;' before "namespace"
[Build Error] [main.o] Error 1
El codigo es este:
--- Código: C++ ---#include <iostream>#include <string>#include <sstream>#include <vector>#include "PaintShop.h"#include "Paint.h"#include "Tool.h"#include "PaintShopException.h" using namespace std; ---> AQUI ME MARCA EL ERROR void addPaint(PaintShop *ps, Paint* paint);void addTool(PaintShop *ps, Tool* tool);void paintInfo(PaintShop* ps, string id); int main(int argc, char *argv[]) { // Creating a PaintShop object // ------------------------- PaintShop *ps = new PaintShop(); // Creating Paint objects and adding them to the paints list of object ps // ---------------------------------------------------------------------- Paint *paintObj1 = new Paint("P1", "Plastic", "Red"); Paint *paintObj2 = new Paint("P2", "Acrylic", "Green"); Paint *paintObj3 = new Paint("P1", "Plastic", "Red"); // repeated object <---- ps->addPaint(paintObj1); ps->addPaint(paintObj2); ps->addPaint(paintObj3); // Creating Tool objects and adding them to the tools list of object ps // -------------------------------------------------------------------- Tool *toolObj1 = new Tool("T1", "Paintbrush"); Tool *toolObj2 = new Tool("T2", "Paintroller"); Tool *toolObj3 = new Tool("T1", "Paintbrusch"); // repeated object <---- ps->addTool(toolObj1); ps->addTool(toolObj2); ps->addTool(toolObj3); // Listing Paint objects Information // --------------------------------- cout << "--------------" << endl; cout << "List of paints" << endl; cout << "--------------" << endl; cout << ps->listPaints() << endl; // Listing Tool objects Information // -------------------------------- cout << "-------------" << endl; cout << "List of tools" << endl; cout << "-------------" << endl; cout << ps->listTools() << endl; // Searching Paints by its id // -------------------------- cout << "-- Information related to Paint with id = P1:" << endl; paintInfo(ps,"P1"); cout << "-- Information related to Paint with id = P3:" << endl; paintInfo(ps,"P3");// This object does not exists <---- // Comparing objects // ----------------- cout << paintObj1->equals(paintObj2) << endl; cout << paintObj1->equals(paintObj3) << endl; cout << "End of the exercise" << endl;} void addPaint(PaintShop *ps, Paint* paint){ try { ps->addPaint(paint); } catch(PaintShopException e) { cout << e.str() << endl; }} void addTool(PaintShop *ps, Tool* tool){ try { ps->addTool(tool); } catch(PaintShopException e) { cout << e.str() << endl; } }void paintInfo(PaintShop *ps, string id){ try { cout << ps->paintInfo(id) << endl; } catch(PaintShopException e) { cout << e.str() << endl; } }
Me he mirado el codigo 20 millones de veces y nose porque sale . Me he mirado las otras clases y todas estan bien..que ocurre? es un problema del dev c++¿??
Eternal Idol:
Seguro esta en la cabecera anterior al namespace: "PaintShopException.h".
Hypocrisy:
Pero si esta bien O_o....que tengo que mirar dentro de las otras clases o algo? pk me lo he mirado tambien y lo veo correcto. --_--'''
Eternal Idol:
El compilador esta esperando un punto y coma, tal vez no lo hayas puesto al final de una clase ... comproba esa cabecera de nuevo y con atencion.
Hypocrisy:
tu has visto algo incohorente???? :wub:
EI: juntando mensajes.
Ya he encontrado el error...era un } que sobraba en la clase paintshop. Compilo y me da Ok. Pero cuando ejecuto el programa me sale un mensaje: abnormal program termination :S. Sabes a que se debe????
Navegación
[#] Página Siguiente
Ir a la versión completa