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 6933203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:48:08+00:00 2026-05-27T11:48:08+00:00

I have a Bullet class that has a function draw(). It want to pass

  • 0

I have a Bullet class that has a function draw(). It want to pass in a static member(object of a SDL_surface class) to this function but not sure how to do it correctly.
my classes :

class AllyBullet: public Bullet
{

        public:

        static SDL_Surface *sprite;
};

class EnemyBullet: public Bullet
{

    public:

        static SDL_Surface *sprite;
};

void Bullet::Draw(SDL_Surface *screen)
{
    DrawSprite(screen,sprite,posX,posY);
}

Bullet does not have a sprite member. How can i write it so that it will know its for the classes that inherit it?

  • 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-27T11:48:08+00:00Added an answer on May 27, 2026 at 11:48 am

    You can make the sprite virtual. Something like this:

    struct Bullet
    {
       virtual Sprite getSprite() const;
       void Draw(SDL_Surface * screen)
       {
          DrawSprite(screen, getSprite(), posX, posY);
       }
       // ...
    };
    
    struct  AllyBullet : public Bullet
    {
       static Sprite s;
       virtual Sprite getSprite() const { return s; }
       // ... 
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this <ul> <ul id=select_opts class=bullet-list style=margin-left:15px;></ul> This javascript code which is meant
Lets say I retrieve an entity object that looks like this: @Entity public class
For an XML file I am creating I have data that contains a bullet
I have a spring application that has configured log4j (via xml) and that runs
I have a level class and a Enemy_control class that is based off an
So I have 2 classes, Bullet and Ship, that are dependent on each other,
I have a Spring project that uses Maven and has several profiles to allow
So i got this bulletContainer class that shoots all these bullets it works &
I am told I have to define an assignment operator for my Bullet class,
We have an application that runs a routine like: protected string _largeFile; Execute() //this

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.