The code as you've written it in your forum post compiles just fine. (After fixing the syntax errors.)
However, if you changed this :
B *bclass;
to this :
A* bclass;
You will get the error you mentioned and it's completely normal and expected. C++ is a statically typed language, so if you have a pointer to class A, you will not be able to access members of class B (directly), even if B derives from A.
What you could do is to cast your pointer :
((B*)bclass)->memberB = 1;
But if you find yourself doing that a lot, your code design probably isn't correct.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Last edited by Xenakios; 07-06-2017 at 11:03 AM.
|