WTF abstract is?
Zhouxuan
pycerl at qq.com
Thu Oct 3 22:07:40 PDT 2013
////////////////////////////////////////////////////////////
//case 1
class A
{
abstract void foo();
}
class B : A
{
static if( __traits(isAbstractClass, typeof(this) ))
{
}
override void foo()
{
}
}
void main()
{
B b = new B();
}
//Error: cannot create instance of abstract class B
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//case 2
abstract class A
{
void foo();
}
class B : A
{
static if( __traits(isAbstractClass, typeof(this) ))
{
}
override void foo()
{
}
}
void main()
{
B b = new B();
}
//Okay
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//case 3
class A
{
abstract void foo();
}
class B : A
{
override void foo()
{
}
}
void main()
{
B b = new B();
}
//Okay
////////////////////////////////////////////////////////////
How awkward it is given that "D is as old as C#"!
Do you guys never used abstract class?
More information about the Digitalmars-d
mailing list