--- /dev/null
+
+int main()
+{
+ try
+ {
+ //throw new Exception("execpcion");
+ assert(0);
+ }
+ catch (Exception e)
+ {
+ printf("%.*s\n", e.msg);
+ }
+ finally
+ {
+ printf("finally\n");
+ }
+ return 0;
+}
int main()
{
int* p = cast(int*) malloc(4 * int.sizeof); // Nunca seran recolectados
- p[3] = 1;
+ p[0] = 1;
+ p[1] = 11;
+ p[2] = 13;
+ p[3] = 17;
+ free(p); // libero
+ p = cast(int*) malloc(4 * int.sizeof); // No se inicializa
for (uint i = 0; i < 4; ++i) printf("p[%d] = %d\n", i, p[i]);
- free(p);
+ free(p); // liberoo se inicializa
return 0;
}
-class C
-{
- private int i;
-}
-
-struct S
-{
- private int i;
-}
+import seguridad_mod;
int main()
{
C c = new C;
+ /* No compila!
+ c._i = 1;
+ int j = c._i;
+ */
printf("c.i = %d\n", c.i);
- c.i = 1;
+ c.i = 2;
printf("c.i = %d\n", c.i);
S s;
+ s._i = 1; // ignora seguridad de struct
+ int j = s._i; // ignora seguridad de struct
printf("s.i = %d\n", s.i);
- s.i = 1;
+ s.i = 2;
printf("s.i = %d\n", s.i);
return 0;
}
--- /dev/null
+
+class C
+{
+ private int _i;
+ int i() { return _i; }
+ int i(int i) { return _i = i; }
+}
+
+struct S
+{
+ private int _i; // ignora seguridad de struct
+ int i() { return _i; }
+ int i(int i) { return _i = i; }
+}
+
int main()
{
+ printf("hola\n");
return 0;
}