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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:27:42+00:00 2026-06-08T05:27:42+00:00

I’ve looked through other questions on this error but they’re not helping me. I’m

  • 0

I’ve looked through other questions on this error but they’re not helping me. I’m still new to C++ and I don’t know if I’m misunderstanding something, misusing something, or just plain missing something but I can’t figure out what and I need some help. My error I’m getting is

SpriteImage does not name a type

Sprite.cpp

#include "Sprite.h"
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <iostream>
#include <vector>

namespace ColdFusion
{
Sprite::Sprite()
{
    bufferSize = 100;
}

void Sprite::addToBuffer(SpriteImage img)
{
    if(SpriteBuffer->size() == bufferSize)
    {
        bufferSize *= 2;
        SpriteBuffer->resize(bufferSize);
    }
    SpriteBuffer->push_back(img);
}

SpriteImage Sprite::getFromBuffer(int index) //**Here is the error**
{
    return SpriteBuffer[index];
}

void Sprite::removeFromBuffer(int index)
{
    SpriteBuffer->erase(SpriteBuffer.begine()+index);
}

void Sprite::removeFromBuffer(SpriteImage index)
{
    for(int j = 0; j <= SpriteBuffer->size(); j++)
    {
        if(SpriteBuffer[j].name == index.name)
        {
            removeFromBuffer(j);
        }
    }
}

void Sprite::applyToScreen(SpriteImage img, SDL_Surface* destination)
{
    applyImage(img.x, img.y,getImage(img.filepath),destination)
}

SDL_Surface* Sprite::getImage(std::string filepath)
{
    SDL_Surface* optimized = NULL;
    SDL_Surface* loaded = NULL;
    loaded = IMG_Load(filepath.c_str());

    if(loaded != NULL)
    {
        optimized = SDL_DisplayFormat(loaded);
        SDL_FreeSurface(loaded);
        return optimized;
    }
    return NULL;
}

void Sprite::applyImage(int x, int y, SDL_Surface* source, SDL_Surface* destination)
{
    SDL_Rect offset;
    offset.x = x;
    offset.y = y;
    SDL_BlitSurface(source, NULL, destination, &offset);
}

Sprite::~Sprite()
{

}
}

Sprite.h

#ifndef SPRITE_H
#define SPRITE_H

#include "SDL/SDL.h"
#include <iostream>
#include <vector>

namespace ColdFusion
{
class Sprite
{
    public:
        Sprite();
        ~Sprite();
        typedef struct SpriteImage{
            int x;
            int y;
            std::string name;
            std::string filepath;
        };
        void addToBuffer(SpriteImage img);
        SpriteImage getFromBuffer(int index);
        void removeFromBuffer(int index);
        void removeFromBuffer(SpriteImage index);
        void applyToScreen(SpriteImage img, SDL_Surface* destination);

    protected:
    private:
        int bufferSize;
        std::vector<SpriteImage> SpriteBuffer[100];
        SDL_Surface* image;
        SDL_Surface* getImage(std::string filepath);
        void applyImage(int x, int y, SDL_Surface* source, SDL_Surface* destination);

};
}

#endif
  • 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-06-08T05:27:43+00:00Added an answer on June 8, 2026 at 5:27 am

    SpriteImage is a nested type and you have to qualify it with the name of its surrounding class to access it, when you are outside of the scope of the containing class. Use Sprite::SpriteImage. It also would make sense to take the parameter to addToBuffer by const& to avoid to many copy constructions. (Probably they end up being optimized away, but it is good practice).

    Instead of a raw array, you can also use std::array or boost::array. On second though: The declaration std::vector<SpriteImage> SpriteBuffer[100]; probably doesn’t declare what you think it does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Does anyone know how can I replace this 2 symbol below from the string
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.