Hi
Iam running into a problem when using classes and inheritance.
I have a base class which contains a member function whos job it is to create and intialize some variables that are shared between other classes. The other classes are inherited from the base class and the variables are accessable from all the classes however i thought that when i called the member function from the base class at the begining of my program that the variables would still be initialised when i use them in other classes but this is obviously not the case , can somebody please set me straight on how to fix this problem , thanks.
RobZombie85
0
Newbie Poster
Recommended Answers
Jump to PostCan you post a short code example of what you're doing?
Jump to PostI notice that those data members aren't static, and thus aren't shared between objects. Each object you create gets its own completely separate copy of non-static data members.
All 7 Replies
Narue
5,707
Bad Cop
Team Colleague
RobZombie85
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
RobZombie85
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
RobZombie85
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.