Can anyone help me fix the singleton?

Oct 29, 2019 at 4:55pm
Hi I'm trying to make a singleton out of the texturemanager class but i'm getting a lot of errors

https://pastebin.com/NmZkTf1T

please can anyone show me the steps to declare it correctly, also why is the declaration of s_pInstance in texturemanager.cpp not working?

main.cpp https://pastebin.com/PXKs6w9e

Game.h https://pastebin.com/nLErPi17

Game.cpp https://pastebin.com/wjhTcY1V

TextureManager.h https://pastebin.com/X3zJT8z0

TextureManager.cpp https://pastebin.com/p4CTDt3R

I am a total noob to c++ so your help is greatly appreciated.

Thanks
Oct 29, 2019 at 5:37pm
read from top to bottom
TextureManager.h:10:9: error: ‘TextureManager’ does not name a type
1
2
3
4
5
6
7
8
9
10
#ifndef __TextureManager__
#define __TextureManager__
 
#include<SDL2/SDL.h>
#include<SDL2/SDL_image.h>
#include<iostream>
#include<string>
#include<map>
 
typedef TextureManager TheTextureManager;
¿what do you think you are doing there?

TextureManager.h: In static member function ‘static TextureManager* TextureManager::Instance()’:
TextureManager.h:33:6: error: ‘s_pInstance’ was not declared in this scope
¿what's `s_pinstance'? ¿where it is declared?
Oct 29, 2019 at 6:15pm
s_pInstance is declared in TextureManager. cpp should i put the typedef there as well?
Oct 30, 2019 at 3:19am
> should i put the typedef there as well?
I'll ask again, ¿what do you think typedef does?

> s_pInstance is declared in TextureManager. cpp
http://www.cplusplus.com/forum/general/113904/#msg622050
don't touch TextureManager.cpp,
declare `s_pInstance' inside the class in TextureManager.h
Nov 1, 2019 at 3:41pm
I tried moving the typedef and the pointer declaration to the .h file but im still getting an error about the pointer declaration, where should i put it in the .h file to get it to compile thanks.

main.cpp https://pastebin.com/DLqNSjAC

Game.h https://pastebin.com/3suDUih1

Game.cpp https://pastebin.com/ZjcMHdv5

TextureManager.h https://pastebin.com/8Q3qZqHR

TextureManager.cpp https://pastebin.com/aHMf2BUA
Topic archived. No new replies allowed.