On Wednesday, 6 April 2016 at 15:10:45 UTC, Andre wrote:
Hi,
With 2.071 following coding does not compile anymore and
somehow I feel it should compile.
The issue is with line "cat.create();".
Cat is a sub type of Animal. Animal "owns" method create and I
want to call the method
create within the class Animal for cat.
Is the error message "no property create for type 'b.cat'"
valid or not?
Kind regards
André
module a;
import b;
class Animal
{
private void create() {}
void foo(Cat cat)
{
cat.create(); // >> no property create for type 'b.cat'
}
}
void main() {}
--------------
module b;
import a;
class Cat: Animal {};
compile with
rdmd a b
Not so up to date on D's OOP stuff, but don't you want create()
to be protected, not private. You can typically access a private
method through a base class, which is what you are doing with
cat.create().