pues eso, en el siguiente codigo en c++ segun el error de g++ me faltan argumentos.
CODE
#include <iostream>
#include <QApplication>
#include <QPushButton>
using namespace std;
// abre una ventana(la funcion incorrecto hace lo mismo)
int correcto(int argc, char *argv[]){
QApplication app(argc, argv);
QPushButton hello("YES!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
int incorrecto(int argc, char *argv[]){
QApplication app(argc, argv);
QPushButton hello("NO!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
//aqui no defino los argumentos int... y char... ya que al hacer una aplicacion gui como main debo ponerlos en main.¿hay algo que no entienda?(como //que en ese caso se les darian unos valores especificos, etc..
int main() {
string y = "uops";
cout << "Respondeme yes: " << endl;
cin >> y;
if (y == "yes") {
correcto();
}
else {
incorrecto();
}
return 0;
}
al menos eso deduzco del siguiente error:
CODE
main.cpp: In function ‘int main()’:
main.cpp:5: error: muy pocos argumentos para function ‘int correcto(int, char**)’
main.cpp:25: error: en este punto en el fichero
main.cpp:12: error: muy pocos argumentos para function ‘int incorrecto(int, char**)’
main.cpp:28: error: en este punto en el fichero
make: *** [main.o] Error 1
EDITO: he comprobado que si las funciones las meto dentro del if funciona, ¿que razón hay para ello?
CODE
#include <iostream>
#include <QApplication>
#include <QPushButton>
using namespace std;
int main(int argc, char *argv[]) {
string y = "Qt";
cout << "Dime yes: " << endl;
cin >> y;
if (y == "yes"){
QApplication app(argc, argv);
QPushButton hello("YES");
hello.resize(100, 30);
hello.show();
return app.exec();
}
else {
QApplication app(argc, argv);
QPushButton hello("NO");
hello.resize(100, 30);
hello.show();
return app.exec();
}
}
PD: no se porque en el code las tabulaciones aparecen tan pequeñas.