Thread: can somebody help me with my homework in c++

  1. #16
    Registered User
    Join Date
    Apr 2011
    Posts
    12
    when I compile it shows only
    Press any key to exit

  2. #17
    Registered User
    Join Date
    Apr 2011
    Posts
    12
    when I compile it shows only
    Press any key to exit

  3. #18
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    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).
    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 ===|
    I don't know if the missing include file will fix most of these errors or not but??

    Jim

  4. #19
    Registered User
    Join Date
    Apr 2011
    Posts
    12
    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.

  5. #20
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    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.
    Code:
    int main() 
    { 
    CRocketSetup MyRocket;
    
    	
    	initscr();
    	return(0);
    }
    Also you should remove the initscr() call from your constructor. This function should be called once and only once.

    After you fix those issues, you are not doing anything except creating an instance of your class.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. More Homework ??
    By dolfaniss in forum C Programming
    Replies: 4
    Last Post: 04-19-2011, 01:25 PM
  2. A little homework help?
    By nwkegan in forum C++ Programming
    Replies: 11
    Last Post: 03-07-2010, 09:45 AM
  3. Do my homework
    By heiroglikano in forum C Programming
    Replies: 3
    Last Post: 05-31-2009, 06:26 AM
  4. help with homework
    By abhiii in forum C Programming
    Replies: 2
    Last Post: 02-13-2009, 01:48 PM