|
-
May 13th, 2005, 05:15 AM
#1
access to a timer variable in base class from a non-derived class
hi, im very new to c++, so any guidance is welcomed.
I'm wondering is it possible to use a variable ( which is a public member of a base class) from a class that is not derived from that base.
my understanding is that public members are accessible by all functions in a program but is this limited to derived classes from the base?
if so is it possible to get around this and what would be the best way.
I have seen the use of friend class which looks like it allows the friend class to access the private members of another class.
Is there something similar for public members.
i get the following type error when compiling the file by trying to use the variable in the following way from the non-derived class.
my_base_class::variable_name
Error : type `my base class' is not a base type for type 'class where I want to use variable_name'
when I just use the variable name directly, the file builds but the program fails with:
Error : undefined reference to `variable_name'
I'd appreciate any help.
thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|