Thread: jumping into c++ ch 11

  1. #1
    Registered User
    Join Date
    Aug 2015
    Posts
    2

    jumping into c++ ch 11

    I typed in the code for the enemy spaceship (sample code 33) like this and still got an error. Not sure what I did incorrectly
    Code:
    #include <iostream>
    using namespace std;
    struct EnemySpaceship
    {
        int x_coordinate;
        int y_coordinate;
        int weapon_power;
    };
    EnemySpaceShip getNewEnemy ()  //error says doesn't name a type
    {                                                                          
        EnemySpaceShip ship;
        ship.x_coordinate = 0;
        ship.y_coordinate = 0;
        ship.weapon_power = 20;
        return ship;
    }
    EnemySpaceShip upgradeWeapons (EnemySpaceShip ship)
    {
        ship.weapon_power += 10;
        return ship;
    }
    int main()
    {
        EnemySpaceShip enemy = getNewEnemy();
        enemy = upgradeWeapons( enemy );
    }

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    EnemySpaceship is not EnemySpaceShip

  3. #3
    Registered User
    Join Date
    Aug 2015
    Posts
    2
    thanks (they can delete this thread now.......)

  4. #4
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Dude, don't even worry. I make those mistakes all the time lol. They get easier to spot over time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Jumping into c++ help
    By Krunchee in forum C++ Programming
    Replies: 3
    Last Post: 08-03-2013, 10:37 PM
  2. after 'jumping to c++'
    By nish1013 in forum C++ Programming
    Replies: 2
    Last Post: 07-09-2013, 08:26 AM
  3. Jumping into C++
    By Tamim Ad Dari in forum C++ Programming
    Replies: 4
    Last Post: 01-12-2013, 08:29 PM
  4. Jumping into C++
    By Tamim Ad Dari in forum C++ Programming
    Replies: 9
    Last Post: 01-11-2013, 09:45 AM
  5. Jumping to OOP in C++ from C
    By meadhikari in forum C++ Programming
    Replies: 6
    Last Post: 07-16-2010, 05:26 AM