I have a strange problem. I can call the function in the Window class(named test) with a pointer to an object I created, but when I cout the pointer it is null(output: 00000000). Is this even possible? That might work, but other classes are not able.
This is where I declare my pointers(normal, right?):
#pragma once
#include "Window.h"
#include "Game.h"
#include "Map.h"
#include "Input.h"
class SN {
public:
SN();
Window * window;
Game * game;
Map * map;
Input * input;
};
This is where I create the objects:
#include "SN.h"
SN::SN(){
game = new Game(this);
window = new Window(this);
map = new Map (this);
input = new Input (this);
}
This is where I put the object pointer of class SN in the pointer object of for example class Window.h :
//CONSTRUCTOR
Window::Window(SN * obj) : sn(obj){
createWindow();
}
declaring sn in Window.h: SN * sn;
Note: I already have forward declared the class SN.
This is how I call a function in the class Window(From the class Game.cpp):
sn->window->test();
I hope I was clear enough, thanks in advance.