How can I inherit like this in AS ?
Class A
{
int a;
A( )
{
a = 0;
}
};
Class B
{
int b;
B( )
{
a = 1;
b = 0;
}
};
But the AS compiler told me that "ERR : The identifier must be an interface", Does it mean must use interface in AS ??
Class inheritance is not yet supported in AngelScript. Classes can implement interfaces thus provide polymorphing. But code reuse through inheritance is not available.
Regards,
Andreas
// Declare an interfaceinterface IA{ void DoSomething();}// Class A implements the interface IAclass A : IA{ void DoSomething() {}}// Class B also implements the interface IAclass B : IA{ void DoSomething() {}}// A handle to IA can hold both a class A and a class BIA @a; @a = @A(); // OK@a = @B(); // OK
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Thanks for reply :)
class A
{
int b;
};
Class B : A
{
};
Class C: A
{
};
how can I use 'b' in Class B and C, I dont want to define the same members between class A and B/C.
Like many implements of interface, I have to define each of them in the implement class. How can I resolve this ?
class A
{
int b;
};
Class B : A
{
};
Class C: A
{
};
how can I use 'b' in Class B and C, I dont want to define the same members between class A and B/C.
Like many implements of interface, I have to define each of them in the implement class. How can I resolve this ?
While inheritance is not possible you can still reuse the code by adding class A as a member to class B and class C.
I know, it's not very nice looking, but it might be sufficient until AngelScript supports inheritance.
Before you ask, I don't know when AngelScript will finally support inheritance.
Regards,
Andreas
class A{ int a; void method() { a = 0; }}class B{ A a; void method() { a.method(); }}
I know, it's not very nice looking, but it might be sufficient until AngelScript supports inheritance.
Before you ask, I don't know when AngelScript will finally support inheritance.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement