User loginNavigation |
This class typeThat may have been discussed before, but I did not find the right search terms for it. In strongly typed object-oriented languages like C++ or Java, how do you designate the type of the class in class methods?
The problem with the code above is that in a derived class, the signature allows newInstance to return an instance of the base class-- the signature is not restrictive enough.
There should be some way to tell the compiler that the type returned is that of the class it is invoked on, is there? Or is there simply a covalence rule for return types such that you would write
...which looks a bit hackish to me. The signature needs to be written again for each subclass. And it needs to be extended to parameters too for eg. clone
What I am looking for is something like:
Any insight is welcome. By Denis Bredelet -jido at 2008-03-28 15:54 | LtU Forum | previous forum topic | next forum topic | other blogs | 7452 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 19 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago