when I compile it shows only
Press any key to exit
when I compile it shows only
Press any key to exit
when I compile it shows only
Press any key to exit
The reason I asked about errors is because the code you posted will not compile for me with out errors.
The following are the errors that I received. NOTE: The line numbers will not match your code because I put everything into one file, (Too lazy to add more files to the project).
I don't know if the missing include file will fix most of these errors or not but??fireworks.cpp|139|error: fireworks.h: No such file or directory|
fireworks.cpp|76|warning: unused parameter ‘TopDistance’|
fireworks.cpp||In function ‘int main()’:|
fireworks.cpp|145|error: ‘rocket’ was not declared in this scope|
fireworks.cpp|145|error: expected ‘;’ before ‘my_rockets’|
fireworks.cpp|150|error: ‘my_rockets’ was not declared in this scope|
fireworks.cpp|150|error: ‘Initialize’ was not declared in this scope|
fireworks.cpp|155|error: ‘Rise’ was not declared in this scope|
fireworks.cpp|156|error: ‘Explode’ was not declared in this scope|
fireworks.cpp|173|error: variable or field ‘Initialize’ declared void|
fireworks.cpp|173|error: ‘rocket’ was not declared in this scope|
fireworks.cpp|173|error: ‘init_rockets’ was not declared in this scope|
fireworks.cpp|173|error: expected primary-expression before ‘int’|
fireworks.cpp|190|error: ‘rocket’ was not declared in this scope|
fireworks.cpp|190|error: ‘rising_rocket’ was not declared in this scope|
fireworks.cpp|191|error: expected ‘,’ or ‘;’ before ‘{’ token|
||=== Build finished: 14 errors, 3 warnings ===|
Jim
I get no error message but simply press any key to exit, and late when I compile. task is to create a rocket setup - class. An object of this class sets up the color pairs and have a method which writes the color codes of the two parents public variables. Rocket-class constructor has a pointer of type CRocketSetup as arguments, so it will rocket to setup - the object's variables. I do not understand how I can do for it to succeed
Code:# include "curses.h" # include "rocket1.h" # include "rocket.h" #include <iostream> using namespace std; CRocketSetup::CRocketSetup() { initscr(); start_color(); init_pair(1, COLOR_CYAN, COLOR_BLACK); init_pair(2, COLOR_RED, COLOR_BLACK); mColorRise = 1; mColorExplosion = 2; curs_set(0); //hide curso } CRocketSetup::~CRocketSetup() { timeout(-1); // turn timeout off printw("\n Press any key to exit \n"); refresh(); getch(); endwin(); //return ;Code:# include "curses.h" #include "Rocket1.h" int main() { CRocketSetup MyRocket; initscr(); return(0); }Code:# ifndef ROCKET1 # define ROCKET1 class CRocketSetup { public: int mColorRise; int mColorExplosion; CRocketSetup(); ~ CRocketSetup(); }; #endif
Last edited by gosse; 04-28-2011 at 07:47 AM.
In main your call to initscr(); should be before you create an instance of your class, it probably should be the first thing done in this program.
Also you should remove the initscr() call from your constructor. This function should be called once and only once.Code:int main() { CRocketSetup MyRocket; initscr(); return(0); }
After you fix those issues, you are not doing anything except creating an instance of your class.
Jim