Accessing function and variable of another C++ class nullptr problem

Shayan.ebz99
Thu, 16 May 2019 17:13:09 +0000
C++

hi everyone, i am really confused by some simple stuff, i am trying to get some values from class A and return that value into class B and do something with the value. first thing that came to mind was that i should create an instance of class A in class B so i will be able to use class A’s public functions and vars. so i made an instance in B.h.

class A* someName;

i tried to use some of functions of someName in B.cpp, but the problem is when i play the game it shows that someName is nullptr. in programming viewsight its true to me. we can use class instances in another classes.
so what the problem can be?

13 posts - 1 participant