Why does the compiler not find the base class function signature? Changing foo( a1 ) to B::foo( a1 ) works.
Code:
class A1 ;
class A2 ;
class B
{
public:
void foo( A1* a1 ) { a1 = 0 ; }
} ;
class C : public B
{
public:
void foo( A2* /*a2*/ )
{
A1* a1 = 0 ;
foo( a1 ) ;
}
} ;
int main()
{
A2* a2 = 0 ;
C c...
Base Class B
|
|
----
| |
| |
D1 D2
public static object GetDerivedClass(Type t1, MyProcess p1)
{
DerivedClass D1 = null;
DerivedClass D2 = null;
if (t1 is typeof(Derived)
{
Process(D1,p1);
return D1;
}
else if(t1 is typeof(Derived)
{
...
Well its simple here you have my vb.net code:
Public Class Class1
Public Overridable ReadOnly Property Name() As String
Get
Return Nothing
End Get
End Property
End Class
Public Class Class2
Inherits Class1
Public Overloads ReadOnly Property Name() As String
Get
Return "Cla...
Hello!
I have run into trouble trying to implement functionality for serializing some classes in my game. I store some data in a raw text file and I want to be able to save and load to/from it.
The details of this, however, are irrelevant. The problem is that I am trying to make each object that is interesting for the save file to be ab...
When a class implements an interface, do the subclasses inherit the implemented interfaces too? For example
class A implements Runnable
{
public void run()
{
// do something
}
}
class B extends A
{
public static void main(String[] args)
{
new Thread(new B()).start(); //works
}
}
does this mean the implem...
I'm doing some work with Genetic Algorithms and want to write my own GA classes. Since a GA can have different ways of doing selection, mutation, cross-over, generating an initial population, calculating fitness, and terminating the algorithm, I need a way to plug in different combinations of these. My initial approach was to have an abs...
for example in PHP
class foo{
function foo($name){ //constructor
$this->name=$name;
}
function sayMyName(){
return $this->name;
}
}
class bar extends foo{
function sayMyName(){
return "subclassed ".$this->name;
}
}
And in JS
function foo(name){
this.name=name;
}
foo.prototype.sayMyName=function(){return th...
How I can get from a module the Class name of the class the module is included ?
module ActMethods
def some_method(*attr_names)
cls = self.class # this doesn't work
end
end
How I can get into the cls variable the name of the class to with this module is loaded ?
...
Hello,
is there a way in JavaScript to inherit private members from a base class to a sub class?
I want to achieve something like this:
function BaseClass() {
var privateProperty = "private";
this.publicProperty = "public";
}
SubClass.prototype = new BaseClass();
SubClass.prototype.constructor = SubClass;
function SubClass() {
...
Hi,
I have an issue that is quite annoying with symfony 1.2 and propel.
I have a model where I have implemented inheritance using the single-table strategy. So, here is an excerpt of my model:
Ad (id, posted_date, description)
then RealEstateAd(location, price, transaction_type) and JobAd(position, requirements, company) which inherit bo...
I have a base class, say BassClass, with some fields, which I made them protected, and some pure virtual functions. Then the derived class, say DerivedClass, like class DerivedClass : public BassClass. Shouldn't DerivedClass inherit the protected fields from BassClass? When I tried to compile the DerivedClass, the compiler complains that...
Alrighty, coding in Perl and just had a quick question. I have class created called SubtitleSite which is basically an abstraction, and a class called podnapisi that inherits SubtitleSite like this:
@ISA = qw(SubtitleSite);
My question is, do I have to use:
use SubtitleSite;
in order to have access to all the methods in SubtitleSit...
In the Python data model reference section on slots there is a list of notes on using __slots__. I am thoroughly confused by the 1st and 6th items, because they seem to be contradicting each other.
First item:
When inheriting from a class without
__slots__, the __dict__ attribute
of that class will always be
accessible, so a __slots...
when we can inherit from base class / interface, why can't we declare a List<>
using same classes / interface
interface A
{ }
class B : A
{ }
class C : B
{ }
class Test
{
static void Main(string[] args)
{
A a = new C(); // OK
List<A> listOfA = new List<C>(); // compile...
I'm having trouble extending a base class that extends Ordered[Base]. My derived class can't extend Ordered[Derived] so can't be used as a key in a TreeMap. If I create a TreeMap[Base] and then just override compare in Derived that works but it's not what I want. I would like to be able to have the derived class as a key. Is there a way ...
Hi to all.
Here's the situation:
There's a base class of type BaseObject ,from which all other classes are derived(i.e. Task : BaseObject).
There's also a base class collection of type BaseObjectCollection which inherits from Dictionary<ulong,BaseObject> and some other collections that inherit from it (i.e. TaskCollection:BaseObjectColle...
I'm working on a game engine in C#. The class I'm working on is called CEntityRegistry, and its job is to keep track of the many instances of CEntity in the game. My goal is to be able to query the CEntityRegistry with a given type, and get a list of each CEntity of that type.
What I'd like to do, therefore, is maintain a map:
private...
I want to extend the VB.NET dictionary object to not bitch about an item being already in the associative array.
This is what i want to do:
Public Class BetterDictionary
Inherits System.Collections.Generic.Dictionary(Of Object, Object)
Public Sub Store(ByRef key As Object, ByVal value As Object)
If Me.ContainsKey(k...
I have quite complex SP which returns base class (basecontent). I have inheritence with about 30+ child classes (like "page", "news", etc).
When I return other types from SP everything works fine, but this one drives me crazy. I am quite experienced with LINQ and already tryied to recreate SP, verified outout, etc.
But this call fails ...
Hi guys!
I have an issue when consuming a web service from a Flex app.
In the backend I have a hierarchy, let's say I have an abstract class Fruit, and 2 implementations: Apple and Orange. Fruit has a property, name, Apple has a property color, and Orange has a property radius.
Then, I have a service wich returns a collection of Fruit. W...