abstract_class.carbon 520 B

123456789101112131415161718192021222324252627
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. abstract class C {
  8. var a: i32;
  9. }
  10. class D {
  11. extend base: C;
  12. var b: i32;
  13. }
  14. fn Main() -> i32 {
  15. var d: D = { .base = {.a = 1}, .b = 2 };
  16. Print("d.a={0}", d.a);
  17. Print("d.b={0}", d.b);
  18. return 0;
  19. }
  20. // CHECK:STDOUT: d.a=1
  21. // CHECK:STDOUT: d.b=2
  22. // CHECK:STDOUT: result: 0