changeset 835:45d6f72f4d18

abstract / override
author thomask
date Thu, 16 Feb 2006 11:43:45 +0000
parents 4a37bb21b9a1
children be9add84456d
files run/a/abstract_16_A.d run/a/abstract_16_B.d
diffstat 2 files changed, 70 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/a/abstract_16_A.d	Thu Feb 16 11:43:45 2006 +0000
@@ -0,0 +1,41 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+module dstress.run.a.abstract_16_A;
+
+class A{
+	int test(){
+		return 1;
+	}
+}
+
+class B : A{
+	abstract override int test();
+}
+
+class C : B{
+	override int test(){
+		return 2;
+	}
+}
+
+int main(){
+	C c = new C();
+
+	if(c.test() != 2){
+		assert(0);
+	}
+
+	B b = c;
+
+	if(b.test() != 2){
+		assert(0);
+	}
+
+	A a = b;
+
+	if(a.test() == 2){
+		return 0;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/a/abstract_16_B.d	Thu Feb 16 11:43:45 2006 +0000
@@ -0,0 +1,29 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+module dstress.run.a.abstract_16_B;
+
+class A{
+	int test(){
+		return 1;
+	}
+}
+
+class B : A{
+	abstract override int test();
+}
+
+class C : B{
+	override int test(){
+		return 2;
+	}
+}
+
+int main(){
+	A a = new A();
+
+	if(a.test() == 1){
+		return 0;
+	}
+}