Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7442031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:06:49+00:00 2026-05-29T11:06:49+00:00

I was attempting to make a simple pokemon text game in c++. I created

  • 0

I was attempting to make a simple pokemon text game in c++.
I created a class for pokemon, and then in my pokemain.cpp tried outputting hp from charmander.
When i try running my pokemonmain.cpp, it says charmander was not declared. Im sure this is a dumb question, but I cant find an answer to it.

Here is my code.

//class named stats
#include <iostream>
using namespace std;

class pokemon
{
    int health, damage;

    public: 

    pokemon (int,int);
    int hp() 
    {
        return (health);
    }

    int dmg()
    {
        return (damage);
    }

};

pokemon::pokemon (int hp, int dmg)
{
    health = hp;
    damage = dmg;


    pokemon charmander (25,3);
    pokemon bulbasaur (20,4);
    pokemon squirtle (30,2);
    cout<<" Charmander has "<<charmander.hp()<<" hp and "<<charmander.dmg()<<" damage.\n";
    cout<<" Bulbasaur has "<<bulbasaur.hp()<<" hp and "<<bulbasaur.dmg()<<" damage.\n";
    cout<<" Squirtle has "<<squirtle.hp()<<" hp and "<<squirtle.dmg()<<" damage.\n";

}

//pokemain.cpp
#include <iostream>
#include "stats.h"
using namespace std;


int main()
{
    cout<<charmander.hp();
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:06:51+00:00Added an answer on May 29, 2026 at 11:06 am

    The variables charmander, bulbausar and squirtle are being declared inside the constructor. Put them in your main and it should work.

    int main(void) {
        pokemon charmander(25,3);
        pokemon bulbausar(25,3);
        pokemon squirtle(25,3);
    
        cout<<" Charmander has "<<charmander.hp()<<" hp and "<<charmander.dmg()<<" damage.\n";
        cout<<" Bulbasaur has "<<bulbasaur.hp()<<" hp and "<<bulbasaur.dmg()<<" damage.\n";
        cout<<" Squirtle has "<<squirtle.hp()<<" hp and "<<squirtle.dmg()<<" damage.\n";
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to make a simple class that serializes itself to disk when
I'm attempting to make a simple game of Pairs for Android. Program Structure Menu.java
I'm attempting to make a simple game of Pairs for Android. Program Structure: Menu.java
I am attempting to make a simple game using C++ and OpenGL and I
I'm attempting to make a simple homebrew game engine/framework in android. I have the
I am attempting to make a simple accordion where the user clicks on level
I'm attempting to make the switch from Windows to ubuntu (am using 12.04 LTS)
I am attempting to make a simple connection to a remote database. I can
I'm attempting to use Raphael to make a small game, and just want a
I am attempting to make a simple connection to a MySql database, located on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.