diff --git a/20230406/ b/20230406/ new file mode 100755 index 0000000000000000000000000000000000000000..e05ff7aa388edd4fe61f40a0c53a47974c48e1ec --- /dev/null +++ b/20230406/ @@ -0,0 +1 @@ +echo "Welt!" diff --git a/20230406/constructors-01.cpp b/20230406/constructors-01.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0f52f34d619335d5ea202d86a8bd07c644c8ce77 --- /dev/null +++ b/20230406/constructors-01.cpp @@ -0,0 +1,19 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } +}; + +int main () +{ + TInteger i; + i.print (); + return 0; +} diff --git a/20230406/constructors-02.cpp b/20230406/constructors-02.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b2d954bbd042dd22ffd8af9c87d49427423f2cbd --- /dev/null +++ b/20230406/constructors-02.cpp @@ -0,0 +1,23 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger (int i) + { + content = i; + } +}; + +int main () +{ + TInteger i; + i.print (); + return 0; +} diff --git a/20230406/constructors-03.cpp b/20230406/constructors-03.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af9082c4fb741528f3a2ce8fe6409c81d4b8f561 --- /dev/null +++ b/20230406/constructors-03.cpp @@ -0,0 +1,23 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger (int i) + { + content = i; + } +}; + +int main () +{ + TInteger i (13); + i.print (); + return 0; +} diff --git a/20230406/constructors-04.cpp b/20230406/constructors-04.cpp new file mode 100644 index 0000000000000000000000000000000000000000..375b3a74c3c4e5d41a97995f1306e6774fab7833 --- /dev/null +++ b/20230406/constructors-04.cpp @@ -0,0 +1,27 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } + TInteger (int i) + { + content = i; + } +}; + +int main () +{ + TInteger i; + i.print (); + return 0; +} diff --git a/20230406/constructors-05.cpp b/20230406/constructors-05.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c78427cc264a21f7aeb99ad2ed3f86b4d7025689 --- /dev/null +++ b/20230406/constructors-05.cpp @@ -0,0 +1,27 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } + TInteger (int i) + { + content = i; + } +}; + +int main () +{ + TInteger i = 13; + i.print (); + return 0; +} diff --git a/20230406/constructors-06.cpp b/20230406/constructors-06.cpp new file mode 100644 index 0000000000000000000000000000000000000000..030d9a71ee3bfb4f2563342374b17d4a36dde4af --- /dev/null +++ b/20230406/constructors-06.cpp @@ -0,0 +1,23 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } +}; + +int main () +{ + TInteger i = 13; + i.print (); + return 0; +} diff --git a/20230406/constructors-07.cpp b/20230406/constructors-07.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c56d215c5325b01699b1324a42bc7ccdec14f71 --- /dev/null +++ b/20230406/constructors-07.cpp @@ -0,0 +1,24 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } +}; + +int main () +{ + TInteger i; + i = 13; + i.print (); + return 0; +} diff --git a/20230406/constructors-08.cpp b/20230406/constructors-08.cpp new file mode 100644 index 0000000000000000000000000000000000000000..64a8379470433874a552143e5d934949bc97d9ab --- /dev/null +++ b/20230406/constructors-08.cpp @@ -0,0 +1,29 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } + TInteger (int i) + { + content = i; + } +}; + +int main () +{ + TInteger i; + TInteger j = 13; + i = j; + i.print (); + return 0; +} diff --git a/20230406/constructors-09.cpp b/20230406/constructors-09.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5c5718ece4634e3e5014435224e42f4ef7a4eaef --- /dev/null +++ b/20230406/constructors-09.cpp @@ -0,0 +1,28 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } + TInteger (int i) + { + content = i; + } +}; + +int main () +{ + TInteger j = 13; + TInteger i = j; + i.print (); + return 0; +} diff --git a/20230406/constructors-10.cpp b/20230406/constructors-10.cpp new file mode 100644 index 0000000000000000000000000000000000000000..82e51947c5846ec013992c1e8369eda154a0b234 --- /dev/null +++ b/20230406/constructors-10.cpp @@ -0,0 +1,32 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } + TInteger (int i) + { + content = i; + } + TInteger (const TInteger &src) + { + content = 2 * src.content; + } +}; + +int main () +{ + TInteger j = 13; + TInteger i = j; + i.print (); + return 0; +} diff --git a/20230406/constructors-11.cpp b/20230406/constructors-11.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b72bef9f16bdef9763bfbb40968410a3956107f8 --- /dev/null +++ b/20230406/constructors-11.cpp @@ -0,0 +1,33 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } + TInteger (int i) + { + content = i; + } + TInteger (const TInteger &src) + { + content = 2 * src.content; + } +}; + +int main () +{ + TInteger j = 13; + TInteger i; + i = j; + i.print (); + return 0; +} diff --git a/20230406/constructors-12.cpp b/20230406/constructors-12.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c609013f146121e3dc865d82e31646c8e015152 --- /dev/null +++ b/20230406/constructors-12.cpp @@ -0,0 +1,38 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } + TInteger (int i) + { + content = i; + } + TInteger (const TInteger &src) + { + content = 2 * src.content; + } + TInteger &operator = (const TInteger &src) + { + content = src.content / 2; + return *this; + } +}; + +int main () +{ + TInteger j = 13; + TInteger i; + i = j; + i.print (); + return 0; +} diff --git a/20230406/constructors-13.cpp b/20230406/constructors-13.cpp new file mode 100644 index 0000000000000000000000000000000000000000..49b94fe130e00f2d814a1556ef10c6e97f82c43f --- /dev/null +++ b/20230406/constructors-13.cpp @@ -0,0 +1,37 @@ +#include <stdio.h> + +class TInteger +{ +private: + int content; +public: + void print () + { + printf ("%d\n", content); + } + TInteger () + { + content = 42; + } + TInteger (int i) + { + content = i; + } + TInteger (const TInteger &src) + { + content = 2 * src.content; + } + TInteger &operator = (const TInteger &src) + { + content = src.content / 2; + return *this; + } +}; + +int main () +{ + TInteger j = 13; + TInteger i = j; + i.print (); + return 0; +} diff --git a/20230406/constructors-14.cpp b/20230406/constructors-14.cpp new file mode 100644 index 0000000000000000000000000000000000000000..06329a0e82830e2ffa160f98caf250dc05136fad --- /dev/null +++ b/20230406/constructors-14.cpp @@ -0,0 +1,27 @@ +#include <stdio.h> + +class TString +{ +private: + const char *content; +public: + void print () + { + printf ("%s\n", content); + } + TString () + { + content = "Hello, world!\n"; + } + TString (const char *s) + { + content = s; + } +}; + +int main () +{ + TString s = "Hallo, Welt!"; + s.print (); + return 0; +} diff --git a/20230406/constructors-15.cpp b/20230406/constructors-15.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6ff60bb5b7e032434c0393a62db8151a4b8ff20f --- /dev/null +++ b/20230406/constructors-15.cpp @@ -0,0 +1,30 @@ +#include <stdio.h> + +class TIntString +{ +private: + int icontent; + const char *content; +public: + void print () + { + printf ("%s %i\n", content, icontent); + } + TIntString () + { + content = "Hello, world!\n"; + icontent = 42; + } + TIntString (const char *s, int i) + { + content = s; + icontent = i; + } +}; + +int main () +{ + TIntString s = { "Hallo, Welt!", 42 }; + s.print (); + return 0; +} diff --git a/20230406/constructors-16.cpp b/20230406/constructors-16.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b33a23943a6243d83530ef8e4387c346bc54a226 --- /dev/null +++ b/20230406/constructors-16.cpp @@ -0,0 +1,30 @@ +#include <stdio.h> + +class TIntString +{ +private: + int icontent; + const char *content; +public: + void print () + { + printf ("%s %i\n", content, icontent); + } + TIntString () + { + content = "Hello, world!\n"; + icontent = 42; + } + TIntString (const char *s, int i) + { + content = s; + icontent = i; + } +}; + +int main () +{ + TIntString s ("Hallo, Welt!", 42); + s.print (); + return 0; +} diff --git a/20230406/constructors-17.cpp b/20230406/constructors-17.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c41b0547c79e11a4036e7c674e367afb01612124 --- /dev/null +++ b/20230406/constructors-17.cpp @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +class TString +{ +private: + char *content; +public: + void print () + { + printf ("%s\n", content); + } + TString (const char *s = "Hello, world!") + { + content = (char *) malloc (strlen (s)); + strcpy (content, s); + } +}; + +int main () +{ + TString s = "Hallo, Welt!"; + s.print (); + return 0; +} diff --git a/20230406/destructors-01.cpp b/20230406/destructors-01.cpp new file mode 100644 index 0000000000000000000000000000000000000000..de9bc07c93c17660963d4ab271fcfbc934e3ba61 --- /dev/null +++ b/20230406/destructors-01.cpp @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +class TString +{ +private: + char *content; +public: + void print () + { + printf ("%s\n", content); + } + TString (const char *s = "Hello, world!") + { + content = (char *) malloc (strlen (s)); + strcpy (content, s); + } + virtual ~TString () + { + free (content); + content = NULL; + } +}; + +int main () +{ + TString s = "Hallo, Welt!"; + s.print (); + return 0; +} diff --git a/20230406/destructors-02.cpp b/20230406/destructors-02.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ee8e1448522da8fb78ec3f0315e20c4f966d7981 --- /dev/null +++ b/20230406/destructors-02.cpp @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +class TString +{ +private: + char *content; +public: + void print () + { + printf ("%s\n", content); + } + TString (const char *s = "Hello, world!") + { + printf ("Constructing TString object\n"); + content = (char *) malloc (strlen (s)); + strcpy (content, s); + } + virtual ~TString () + { + printf ("Destructing TString object\n"); + free (content); + content = NULL; + } +}; + +int main () +{ + TString s = "Hallo, Welt!"; + s.print (); + return 0; +} diff --git a/20230406/destructors-03.cpp b/20230406/destructors-03.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2f43e95007ccb91810a9938cd5839a8bfcfa0870 --- /dev/null +++ b/20230406/destructors-03.cpp @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +class TString +{ +private: + char *content; +public: + void print () + { + printf ("%s\n", content); + } + TString (const char *s = "Hello, world!") + { + printf ("Constructing TString object\n"); + content = (char *) malloc (strlen (s)); + strcpy (content, s); + } + virtual ~TString () + { + printf ("Destructing TString object\n"); + free (content); + content = NULL; + } +}; + +int bye () +{ + printf ("Bye!\n"); + return 0; +} + +int main () +{ + TString s = "Hallo, Welt!"; + s.print (); + return bye (); +} diff --git a/20230406/destructors-03.s b/20230406/destructors-03.s new file mode 100644 index 0000000000000000000000000000000000000000..3878f2edb39fca9b765d87acbb5ad31fa3a38108 --- /dev/null +++ b/20230406/destructors-03.s @@ -0,0 +1,218 @@ + .file "destructors-03.cpp" + .text + .section .rodata._ZN7TStringD2Ev.str1.1,"aMS",@progbits,1 +.LC0: + .string "Destructing TString object" + .section .text._ZN7TStringD2Ev,"axG",@progbits,_ZN7TStringD5Ev,comdat + .align 2 + .weak _ZN7TStringD2Ev + .type _ZN7TStringD2Ev, @function +_ZN7TStringD2Ev: +.LFB51: + .cfi_startproc + .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 + .cfi_lsda 0x1b,.LLSDA51 + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + movq %rdi, %rbx + leaq 16+_ZTV7TString(%rip), %rax + movq %rax, (%rdi) + leaq .LC0(%rip), %rdi + call puts@PLT + movq 8(%rbx), %rdi + call free@PLT + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE51: + .globl __gxx_personality_v0 + .section .gcc_except_table._ZN7TStringD2Ev,"aG",@progbits,_ZN7TStringD5Ev,comdat +.LLSDA51: + .byte 0xff + .byte 0xff + .byte 0x1 + .uleb128 .LLSDACSE51-.LLSDACSB51 +.LLSDACSB51: +.LLSDACSE51: + .section .text._ZN7TStringD2Ev,"axG",@progbits,_ZN7TStringD5Ev,comdat + .size _ZN7TStringD2Ev, .-_ZN7TStringD2Ev + .weak _ZN7TStringD1Ev + .set _ZN7TStringD1Ev,_ZN7TStringD2Ev + .section .text._ZN7TStringD0Ev,"axG",@progbits,_ZN7TStringD5Ev,comdat + .align 2 + .weak _ZN7TStringD0Ev + .type _ZN7TStringD0Ev, @function +_ZN7TStringD0Ev: +.LFB53: + .cfi_startproc + .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 + .cfi_lsda 0x1b,.LLSDA53 + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + movq %rdi, %rbx + leaq 16+_ZTV7TString(%rip), %rax + movq %rax, (%rdi) + leaq .LC0(%rip), %rdi + call puts@PLT + movq 8(%rbx), %rdi + call free@PLT + movl $16, %esi + movq %rbx, %rdi + call _ZdlPvm@PLT + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE53: + .section .gcc_except_table._ZN7TStringD0Ev,"aG",@progbits,_ZN7TStringD5Ev,comdat +.LLSDA53: + .byte 0xff + .byte 0xff + .byte 0x1 + .uleb128 .LLSDACSE53-.LLSDACSB53 +.LLSDACSB53: +.LLSDACSE53: + .section .text._ZN7TStringD0Ev,"axG",@progbits,_ZN7TStringD5Ev,comdat + .size _ZN7TStringD0Ev, .-_ZN7TStringD0Ev + .section .rodata.str1.1,"aMS",@progbits,1 +.LC1: + .string "Bye!" + .text + .globl _Z3byev + .type _Z3byev, @function +_Z3byev: +.LFB54: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + leaq .LC1(%rip), %rdi + call puts@PLT + movl $0, %eax + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE54: + .size _Z3byev, .-_Z3byev + .section .rodata.str1.1 +.LC2: + .string "Constructing TString object" + .text + .globl main + .type main, @function +main: +.LFB55: + .cfi_startproc + .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 + .cfi_lsda 0x1b,.LLSDA55 + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + subq $8, %rsp + .cfi_def_cfa_offset 32 + leaq .LC2(%rip), %rdi +.LEHB0: + call puts@PLT +.LEHE0: + movl $12, %edi + call malloc@PLT + movq %rax, %rbx + movabsq $6278066737626505544, %rax + movq %rax, (%rbx) + movl $561278053, 8(%rbx) + movb $0, 12(%rbx) + movq %rbx, %rdi +.LEHB1: + call puts@PLT + leaq .LC1(%rip), %rdi + call puts@PLT +.LEHE1: + jmp .L13 +.L9: + movq %rax, %rbp + leaq .LC0(%rip), %rdi + call puts@PLT + movq %rbx, %rdi + call free@PLT + movq %rbp, %rdi +.LEHB2: + call _Unwind_Resume@PLT +.LEHE2: +.L13: + leaq .LC0(%rip), %rdi + call puts@PLT + movq %rbx, %rdi + call free@PLT + movl $0, %eax + addq $8, %rsp + .cfi_def_cfa_offset 24 + popq %rbx + .cfi_def_cfa_offset 16 + popq %rbp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE55: + .section .gcc_except_table,"a",@progbits +.LLSDA55: + .byte 0xff + .byte 0xff + .byte 0x1 + .uleb128 .LLSDACSE55-.LLSDACSB55 +.LLSDACSB55: + .uleb128 .LEHB0-.LFB55 + .uleb128 .LEHE0-.LEHB0 + .uleb128 0 + .uleb128 0 + .uleb128 .LEHB1-.LFB55 + .uleb128 .LEHE1-.LEHB1 + .uleb128 .L9-.LFB55 + .uleb128 0 + .uleb128 .LEHB2-.LFB55 + .uleb128 .LEHE2-.LEHB2 + .uleb128 0 + .uleb128 0 +.LLSDACSE55: + .text + .size main, .-main + .weak _ZTS7TString + .section .rodata._ZTS7TString,"aG",@progbits,_ZTS7TString,comdat + .align 8 + .type _ZTS7TString, @object + .size _ZTS7TString, 9 +_ZTS7TString: + .string "7TString" + .weak _ZTI7TString + .section .data.rel.ro._ZTI7TString,"awG",@progbits,_ZTI7TString,comdat + .align 8 + .type _ZTI7TString, @object + .size _ZTI7TString, 16 +_ZTI7TString: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS7TString + .weak _ZTV7TString + .section .data.rel.ro.local._ZTV7TString,"awG",@progbits,_ZTV7TString,comdat + .align 8 + .type _ZTV7TString, @object + .size _ZTV7TString, 32 +_ZTV7TString: + .quad 0 + .quad _ZTI7TString + .quad _ZN7TStringD1Ev + .quad _ZN7TStringD0Ev + .hidden DW.ref.__gxx_personality_v0 + .weak DW.ref.__gxx_personality_v0 + .section .data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat + .align 8 + .type DW.ref.__gxx_personality_v0, @object + .size DW.ref.__gxx_personality_v0, 8 +DW.ref.__gxx_personality_v0: + .quad __gxx_personality_v0 + .ident "GCC: (Debian 8.3.0-6) 8.3.0" + .section .note.GNU-stack,"",@progbits diff --git a/20230406/destructors-04.cpp b/20230406/destructors-04.cpp new file mode 100644 index 0000000000000000000000000000000000000000..837d2e628737cd8727a50f6fa71db1615b3b5ec1 --- /dev/null +++ b/20230406/destructors-04.cpp @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +class TString +{ +private: + char *content; +public: + void print () + { + printf ("%s\n", content); + } + TString (const char *s = "Hello, world!") + { + printf ("Constructing TString object\n"); + content = (char *) malloc (strlen (s)); + strcpy (content, s); + } + virtual ~TString () + { + printf ("Destructing TString object\n"); + free (content); + content = NULL; + } +}; + +int bye () +{ + printf ("Bye!\n"); + return 0; +} + +int main () +{ + TString *s = new TString ("Hallo, Welt!"); + s->print (); + return bye (); +} diff --git a/20230406/destructors-05.cpp b/20230406/destructors-05.cpp new file mode 100644 index 0000000000000000000000000000000000000000..324caeb6d6816f115a02713e703225998aa936ee --- /dev/null +++ b/20230406/destructors-05.cpp @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +class TString +{ +private: + char *content; +public: + void print () + { + printf ("%s\n", content); + } + TString (const char *s = "Hello, world!") + { + printf ("Constructing TString object\n"); + content = (char *) malloc (strlen (s)); + strcpy (content, s); + } + virtual ~TString () + { + printf ("Destructing TString object\n"); + free (content); + content = NULL; + } +}; + +int bye () +{ + printf ("Bye!\n"); + return 0; +} + +int main () +{ + TString *s = new TString ("Hallo, Welt!"); + s->print (); + delete s; + return bye (); +} diff --git a/20230406/objects-28.cpp b/20230406/objects-28.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cecd4ddcd264ceec252af98ffe02056eccc40e75 --- /dev/null +++ b/20230406/objects-28.cpp @@ -0,0 +1,103 @@ +#include <stdio.h> + +class TBase +{ +public: + virtual void print (); + void pront (); +}; + +class TInteger: public TBase +{ +private: + int content; +public: + virtual void print (); + void pront (); + void set (int i); + TInteger (int i); + friend int main (); +}; + +class TString: public TBase +{ +private: + const char *content; +public: + virtual void print (); + void pront (); + void set (const char *s); + TString (const char *s); + friend int main (); +}; + +void TBase::pront () +{ + printf ("Base\n"); +} + +void TBase::print () +{ + printf ("Base\n"); +} + +void TInteger::print () +{ + printf ("Integer: %d\n", content); +} + +void TInteger::pront () +{ + printf ("Integer\n"); +} + +void TInteger::set (int i) +{ + content = i; +} + +TInteger::TInteger (int i) +{ + content = i; +} + +void TString::print () +{ + printf ("String: \"%s\"\n", content); +} + +void TString::pront () +{ + printf ("IString\n"); +} + +void TString::set (const char *s) +{ + content = s; +} + +TString::TString (const char *s) +{ + content = s; +} + +int main (void) +{ + TBase *object[] = { new TInteger (42), + new TString ("Hello, world!"), + NULL }; + + dynamic_cast <TInteger *> (object[0])->content = 137; + dynamic_cast <TString *> (object[1])->content = "Hallo, Welt!"; + + for (int i = 0; object[i]; i++) + { + object[i]->print (); + object[i]->pront (); + } + + for (int i = 0; object[i]; i++) + delete object[i]; + + return 0; +} diff --git a/20230406/objects-28a.cpp b/20230406/objects-28a.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c556ac4741dfe7befb30c5cfc41ebfb206b261f1 --- /dev/null +++ b/20230406/objects-28a.cpp @@ -0,0 +1,109 @@ +#include <stdio.h> + +class TBase +{ +public: + virtual void print (); + void pront (); + ~TBase (); +}; + +TBase::~TBase () +{ + /* empty */ +} + +class TInteger: public TBase +{ +private: + int content; +public: + virtual void print (); + void pront (); + void set (int i); + TInteger (int i); + friend int main (); +}; + +class TString: public TBase +{ +private: + const char *content; +public: + virtual void print (); + void pront (); + void set (const char *s); + TString (const char *s); + friend int main (); +}; + +void TBase::pront () +{ + printf ("Base\n"); +} + +void TBase::print () +{ + printf ("Base\n"); +} + +void TInteger::print () +{ + printf ("Integer: %d\n", content); +} + +void TInteger::pront () +{ + printf ("Integer\n"); +} + +void TInteger::set (int i) +{ + content = i; +} + +TInteger::TInteger (int i) +{ + content = i; +} + +void TString::print () +{ + printf ("String: \"%s\"\n", content); +} + +void TString::pront () +{ + printf ("IString\n"); +} + +void TString::set (const char *s) +{ + content = s; +} + +TString::TString (const char *s) +{ + content = s; +} + +int main (void) +{ + TBase *object[] = { new TInteger (42), + new TString ("Hello, world!"), + NULL }; + + dynamic_cast <TInteger *> (object[0])->content = 137; + dynamic_cast <TString *> (object[1])->content = "Hallo, Welt!"; + + for (int i = 0; object[i]; i++) + { + object[i]->print (); + object[i]->pront (); + } + + for (int i = 0; object[i]; i++) + delete object[i]; + + return 0; +} diff --git a/20230406/objects-28b.cpp b/20230406/objects-28b.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86cb90366fa88a915d697b5c5a6d8495a293e1f0 --- /dev/null +++ b/20230406/objects-28b.cpp @@ -0,0 +1,109 @@ +#include <stdio.h> + +class TBase +{ +public: + virtual void print (); + void pront (); + virtual ~TBase (); +}; + +TBase::~TBase () +{ + /* empty */ +} + +class TInteger: public TBase +{ +private: + int content; +public: + virtual void print (); + void pront (); + void set (int i); + TInteger (int i); + friend int main (); +}; + +class TString: public TBase +{ +private: + const char *content; +public: + virtual void print (); + void pront (); + void set (const char *s); + TString (const char *s); + friend int main (); +}; + +void TBase::pront () +{ + printf ("Base\n"); +} + +void TBase::print () +{ + printf ("Base\n"); +} + +void TInteger::print () +{ + printf ("Integer: %d\n", content); +} + +void TInteger::pront () +{ + printf ("Integer\n"); +} + +void TInteger::set (int i) +{ + content = i; +} + +TInteger::TInteger (int i) +{ + content = i; +} + +void TString::print () +{ + printf ("String: \"%s\"\n", content); +} + +void TString::pront () +{ + printf ("IString\n"); +} + +void TString::set (const char *s) +{ + content = s; +} + +TString::TString (const char *s) +{ + content = s; +} + +int main (void) +{ + TBase *object[] = { new TInteger (42), + new TString ("Hello, world!"), + NULL }; + + dynamic_cast <TInteger *> (object[0])->content = 137; + dynamic_cast <TString *> (object[1])->content = "Hallo, Welt!"; + + for (int i = 0; object[i]; i++) + { + object[i]->print (); + object[i]->pront (); + } + + for (int i = 0; object[i]; i++) + delete object[i]; + + return 0; +} diff --git a/20230406/objects-29.cpp b/20230406/objects-29.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1eb555e36c348bc626146fccb07a6a2e386ba33c --- /dev/null +++ b/20230406/objects-29.cpp @@ -0,0 +1,96 @@ +#include <stdio.h> + +class TBase +{ +public: + + void print () + { + printf ("Base\n"); + } + + virtual void pront () + { + printf ("Base\n"); + } + +}; + +class TInteger: public TBase +{ +private: + int content; +public: + friend int main (); + + void print () + { + printf ("Integer: %d\n", content); + } + + void pront () + { + printf ("Integer\n"); + } + + void set (int i) + { + content = i; + } + + TInteger (int i) + { + content = i; + } + +}; + +class TString: public TBase +{ +private: + const char *content; +public: + friend int main (); + + void print () + { + printf ("String: \"%s\"\n", content); + } + + void pront () + { + printf ("String\n"); + } + + void set (const char *s) + { + content = s; + } + + TString (const char *s) + { + content = s; + } + +}; + +int main (void) +{ + TBase *object[] = { new TInteger (42), + new TString ("Hello, world!"), + NULL }; + + dynamic_cast <TInteger *> (object[0])->content = 137; + dynamic_cast <TString *> (object[1])->content = "Hallo, Welt!"; + + for (int i = 0; object[i]; i++) + { + object[i]->print (); + object[i]->pront (); + } + + for (int i = 0; object[i]; i++) + delete object[i]; + + return 0; +} diff --git a/20230406/objects-30.cpp b/20230406/objects-30.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a0c75424f3a363e7b92be3cd89c11da4b4aa7121 --- /dev/null +++ b/20230406/objects-30.cpp @@ -0,0 +1,96 @@ +#include <stdio.h> + +class TBase +{ +public: + + virtual void print () + { + printf ("Base\n"); + } + + void pront () + { + printf ("Base\n"); + } + +}; + +class TInteger: public TBase +{ +private: + int content; +public: + friend int main (); + + virtual void print () + { + printf ("Integer: %d\n", content); + } + + void pront () + { + printf ("Integer\n"); + } + + void set (int i) + { + content = i; + } + + TInteger (int i) + { + content = i; + } + +}; + +class TString: public TBase +{ +private: + const char *content; +public: + friend int main (); + + virtual void print () + { + printf ("String: \"%s\"\n", content); + } + + void pront () + { + printf ("String\n"); + } + + void set (const char *s) + { + content = s; + } + + TString (const char *s) + { + content = s; + } + +}; + +int main (void) +{ + TBase *object[] = { new TInteger (42), + new TString ("Hello, world!"), + NULL }; + + dynamic_cast <TInteger *> (object[0])->content = 137; + dynamic_cast <TString *> (object[1])->content = "Hallo, Welt!"; + + for (int i = 0; object[i]; i++) + { + object[i]->print (); + object[i]->pront (); + } + + for (int i = 0; object[i]; i++) + delete object[i]; + + return 0; +} diff --git a/20230406/objects-31.cpp b/20230406/objects-31.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c30eaf3cac3628640b054f024bb94b8434970a4a --- /dev/null +++ b/20230406/objects-31.cpp @@ -0,0 +1,14 @@ +#include <stdio.h> + +class TFoo +{ +public: + static int content; +}; + +int main () +{ + TFoo::content = 42; + printf ("Answer: %d\n", TFoo::content); + return 0; +} diff --git a/20230406/objects-32.cpp b/20230406/objects-32.cpp new file mode 100644 index 0000000000000000000000000000000000000000..51798d96da2b05081719d1a1c7311e80473c66d3 --- /dev/null +++ b/20230406/objects-32.cpp @@ -0,0 +1,16 @@ +#include <stdio.h> + +class TFoo +{ +public: + static int content; +}; + +int TFoo::content; + +int main () +{ + TFoo::content = 42; + printf ("Answer: %d\n", TFoo::content); + return 0; +} diff --git a/20230406/objects-33.cpp b/20230406/objects-33.cpp new file mode 100644 index 0000000000000000000000000000000000000000..15f4157651bed317c69677f4c03b02ce5d041b61 --- /dev/null +++ b/20230406/objects-33.cpp @@ -0,0 +1,16 @@ +#include <stdio.h> + +class TFoo +{ +public: + static int content; +}; + +int TFoo::content = 42; + +int main () +{ + TFoo bla; + printf ("Answer: %d\n", bla.content); + return 0; +} diff --git a/20230406/objects-34.cpp b/20230406/objects-34.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d3447cf9e4701e53b1fb0c23f47c1a9b0ae9a96d --- /dev/null +++ b/20230406/objects-34.cpp @@ -0,0 +1,18 @@ +#include <stdio.h> + +class TFoo +{ +public: + static int content; +}; + +int TFoo::content = 42; + +int main () +{ + TFoo bla; + TFoo blubb; + bla.content = 137; + printf ("Answer: %d\n", blubb.content); + return 0; +} diff --git a/20230406/objects-35.cpp b/20230406/objects-35.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9bda597938c2566d597fbd3b9dc4b76268539ec3 --- /dev/null +++ b/20230406/objects-35.cpp @@ -0,0 +1,22 @@ +#include <stdio.h> + +class TFoo +{ +public: + static int content; + + static void hello () + { + printf ("Hello, world!\n"); + } + +}; + +int TFoo::content = 42; + +int main () +{ + TFoo bla; + bla.hello (); + return 0; +} diff --git a/20230406/objects-36.cpp b/20230406/objects-36.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1fd93a6a6cafda48e4c744085605bb4eea766cf9 --- /dev/null +++ b/20230406/objects-36.cpp @@ -0,0 +1,27 @@ +#include <stdio.h> + +class TFoo +{ +private: + int content; + +public: + + TFoo (int i) + { + content = i; + } + + void hello () + { + printf ("The answer is: %d\n", content); + } + +}; + +int main () +{ + TFoo bla (42); + bla.hello (); + return 0; +} diff --git a/20230406/objects-37.cpp b/20230406/objects-37.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fe9e40378fccf44895327b9b62d427351b2e5c95 --- /dev/null +++ b/20230406/objects-37.cpp @@ -0,0 +1,27 @@ +#include <stdio.h> + +class TFoo +{ +private: + int content; + +public: + + TFoo (int i) + { + content = i; + } + + static void hello () + { + printf ("The answer is: %d\n", content); + } + +}; + +int main () +{ + TFoo bla (42); + bla.hello (); + return 0; +} diff --git a/20230406/objects-38.cpp b/20230406/objects-38.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c25df640b07fb1b0bc37cfe8df2c76329c5fc86d --- /dev/null +++ b/20230406/objects-38.cpp @@ -0,0 +1,29 @@ +#include <stdio.h> + +class TFoo +{ +private: + static int content; + +public: + + TFoo (int i) + { + content = i; + } + + static void hello () + { + printf ("The answer is: %d\n", content); + } + +}; + +int TFoo::content; + +int main () +{ + TFoo bla (42); + bla.hello (); + return 0; +} diff --git a/20230406/objects-39.cpp b/20230406/objects-39.cpp new file mode 100644 index 0000000000000000000000000000000000000000..abc1adc7a586ec4985cbf501db5b05c27a9c7c5b --- /dev/null +++ b/20230406/objects-39.cpp @@ -0,0 +1,28 @@ +#include <stdio.h> + +class TFoo +{ +private: + static int content; + +public: + + TFoo (int i) + { + content = i; + } + + static void hello () + { + printf ("The answer is: %d\n", content); + } + +}; + +int TFoo::content; + +int main () +{ + TFoo::hello (); + return 0; +} diff --git a/20230406/objects-40.cpp b/20230406/objects-40.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f8af3e5de379b92847bf7512d84d037b7434e5ae --- /dev/null +++ b/20230406/objects-40.cpp @@ -0,0 +1,28 @@ +#include <stdio.h> + +class TFoo +{ +public: + static int content; + static const int answer = 42; + + TFoo (int i) + { + content = i; + } + + static void hello () + { + printf ("The answer is: %d\n", content); + } + +}; + +int TFoo::content; + +int main () +{ + TFoo::content = TFoo::answer; + TFoo::hello (); + return 0; +} diff --git a/20230406/strings-01.cpp b/20230406/strings-01.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d0624e4fecf5362f51a76f3b007187b6890adfa7 --- /dev/null +++ b/20230406/strings-01.cpp @@ -0,0 +1,9 @@ +#include <iostream> +#include <string> + +int main () +{ + std::string hello = "Hello, world!"; + std::cout << hello << std::endl; + return 0; +} diff --git a/20230406/strings-01.s b/20230406/strings-01.s new file mode 100644 index 0000000000000000000000000000000000000000..fa84b9fe963d319cb7a7fe4a7d737929632f2bfd --- /dev/null +++ b/20230406/strings-01.s @@ -0,0 +1,117 @@ + .file "strings-01.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Hello, world!" + .text + .globl main + .type main, @function +main: +.LFB1540: + .cfi_startproc + .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 + .cfi_lsda 0x1b,.LLSDA1540 + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $48, %rsp + .cfi_def_cfa_offset 64 + leaq 47(%rsp), %rdx + movq %rsp, %rdi + leaq .LC0(%rip), %rsi +.LEHB0: + call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcRKS3_@PLT +.LEHE0: + movq 8(%rsp), %rdx + movq (%rsp), %rsi + leaq _ZSt4cout(%rip), %rdi +.LEHB1: + call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT + movq %rax, %rdi + call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT +.LEHE1: + movq (%rsp), %rdi + leaq 16(%rsp), %rax + cmpq %rax, %rdi + je .L6 + call _ZdlPv@PLT +.L6: + movl $0, %eax + addq $48, %rsp + .cfi_remember_state + .cfi_def_cfa_offset 16 + popq %rbx + .cfi_def_cfa_offset 8 + ret +.L5: + .cfi_restore_state + movq %rax, %rbx + movq (%rsp), %rdi + leaq 16(%rsp), %rax + cmpq %rax, %rdi + je .L4 + call _ZdlPv@PLT +.L4: + movq %rbx, %rdi +.LEHB2: + call _Unwind_Resume@PLT +.LEHE2: + .cfi_endproc +.LFE1540: + .globl __gxx_personality_v0 + .section .gcc_except_table,"a",@progbits +.LLSDA1540: + .byte 0xff + .byte 0xff + .byte 0x1 + .uleb128 .LLSDACSE1540-.LLSDACSB1540 +.LLSDACSB1540: + .uleb128 .LEHB0-.LFB1540 + .uleb128 .LEHE0-.LEHB0 + .uleb128 0 + .uleb128 0 + .uleb128 .LEHB1-.LFB1540 + .uleb128 .LEHE1-.LEHB1 + .uleb128 .L5-.LFB1540 + .uleb128 0 + .uleb128 .LEHB2-.LFB1540 + .uleb128 .LEHE2-.LEHB2 + .uleb128 0 + .uleb128 0 +.LLSDACSE1540: + .text + .size main, .-main + .type _GLOBAL__sub_I_main, @function +_GLOBAL__sub_I_main: +.LFB2030: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + leaq _ZStL8__ioinit(%rip), %rdi + call _ZNSt8ios_base4InitC1Ev@PLT + leaq __dso_handle(%rip), %rdx + leaq _ZStL8__ioinit(%rip), %rsi + movq _ZNSt8ios_base4InitD1Ev@GOTPCREL(%rip), %rdi + call __cxa_atexit@PLT + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE2030: + .size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main + .section .init_array,"aw" + .align 8 + .quad _GLOBAL__sub_I_main + .local _ZStL8__ioinit + .comm _ZStL8__ioinit,1,1 + .hidden DW.ref.__gxx_personality_v0 + .weak DW.ref.__gxx_personality_v0 + .section .data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat + .align 8 + .type DW.ref.__gxx_personality_v0, @object + .size DW.ref.__gxx_personality_v0, 8 +DW.ref.__gxx_personality_v0: + .quad __gxx_personality_v0 + .hidden __dso_handle + .ident "GCC: (Debian 8.3.0-6) 8.3.0" + .section .note.GNU-stack,"",@progbits diff --git a/20230406/strings-02.cpp b/20230406/strings-02.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b45d0441ef361050f443cad28a81781bc04e0f0e --- /dev/null +++ b/20230406/strings-02.cpp @@ -0,0 +1,10 @@ +#include <iostream> +#include <string> + +int main () +{ + std::string hello = "Hello"; + hello = hello + ", world!"; + std::cout << hello << std::endl; + return 0; +} diff --git a/20230406/strings-03.cpp b/20230406/strings-03.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f4c771bd3685fba9e8dcc16f517447af5aaa6ac --- /dev/null +++ b/20230406/strings-03.cpp @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <string> + +int main () +{ + std::string hello = "Hello, world!"; + printf ("%s\n", hello); + return 0; +} diff --git a/20230406/strings-04.cpp b/20230406/strings-04.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ada52042b0ec55f63b54e20fdc348755a4b92d3d --- /dev/null +++ b/20230406/strings-04.cpp @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <string> + +int main () +{ + std::string hello = "Hello, world!"; + printf ("%zd\n", sizeof (hello)); + return 0; +} diff --git a/20230406/strings-05.cpp b/20230406/strings-05.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8533c3709b41e5bfb6a0e5276a99a77eb8a2d2ba --- /dev/null +++ b/20230406/strings-05.cpp @@ -0,0 +1,9 @@ +#include <iostream> +#include <string> + +int main () +{ + std::string hello = "Hello, world!\000Hallo, Welt!"; + std::cout << hello << std::endl; + return 0; +} diff --git a/20230406/strings-06.cpp b/20230406/strings-06.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e1c7960a0ebdeb92b8ca014fa383868e6280316b --- /dev/null +++ b/20230406/strings-06.cpp @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <string> + +int main () +{ + std::string hello = "Hello, world!"; + printf ("%s\n", hello.c_str ()); + return 0; +} diff --git a/20230406/strings-07.cpp b/20230406/strings-07.cpp new file mode 100644 index 0000000000000000000000000000000000000000..25d288bc967ae297f1539c6ac3b8b78fea66a04d --- /dev/null +++ b/20230406/strings-07.cpp @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main () +{ + char hello[42]; + sprintf (hello, "The answer is: %d", 42); + printf ("%s\n", hello); + return 0; +} diff --git a/20230406/strings-08.cpp b/20230406/strings-08.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d83567f1f91f98a785d72e4ec4aada70a8a58afe --- /dev/null +++ b/20230406/strings-08.cpp @@ -0,0 +1,11 @@ +#include <iostream> +#include <string> +#include <sstream> + +int main () +{ + std::ostringstream hello; + hello << "The answer is: " << 42; + std::cout << hello << std::endl; + return 0; +} diff --git a/20230406/strings-09.cpp b/20230406/strings-09.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7fd9239b79b6eec570b424d6a95ffc394cd77eba --- /dev/null +++ b/20230406/strings-09.cpp @@ -0,0 +1,11 @@ +#include <iostream> +#include <string> +#include <sstream> + +int main () +{ + std::ostringstream hello; + hello << "The answer is: " << 42; + std::cout << hello.str () << std::endl; + return 0; +} diff --git a/20230406/strings-10.cpp b/20230406/strings-10.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc05c5ddd0a15eda9ca59397e6ea022c4f541dcb --- /dev/null +++ b/20230406/strings-10.cpp @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <string> +#include <sstream> + +int main () +{ + std::ostringstream hello; + hello << "The answer is: " << 42; + printf ("%s\n", hello.str ().c_str ()); + return 0; +} diff --git a/20230406/strings-11.cpp b/20230406/strings-11.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b5cfc39e0532099e5dd47e036b03b6d0334c4f58 --- /dev/null +++ b/20230406/strings-11.cpp @@ -0,0 +1,8 @@ +#include <iostream> + +int main () +{ + const char *hello = "Hello, world!"; + std::cout << hello << std::endl; + return 0; +} diff --git a/20230406/strings-12.cpp b/20230406/strings-12.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6a78d3c0573ee78e0563abeda4016063713389f --- /dev/null +++ b/20230406/strings-12.cpp @@ -0,0 +1,8 @@ +#include <iostream> + +int main () +{ + char *hello = "Hello, world!"; + std::cout << hello << std::endl; + return 0; +} diff --git a/20230406/unicode-01.cpp b/20230406/unicode-01.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6e1d337bef3569ad70840a966995647a3615e653 --- /dev/null +++ b/20230406/unicode-01.cpp @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main () +{ + int Ä = 42; + printf ("Die Äntwort lautet: %d\n", Ä); + return 0; +} diff --git "a/20230406/\303\244" "b/20230406/\303\244" new file mode 100755 index 0000000000000000000000000000000000000000..50002fa37836c87eb695c6e638a61a09398ea431 --- /dev/null +++ "b/20230406/\303\244" @@ -0,0 +1 @@ +echo "Hallo!"