Advertisement
jewalky

Untitled

Feb 15th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. class UnrelatedClass
  2. {
  3.     static void TestFunc()
  4.     {
  5.    
  6.     }
  7. }
  8.  
  9. class TestInventory : Inventory
  10. {
  11.     unsafe int a;
  12.     int b;
  13.  
  14.     virtual unsafe void TestFunc2()
  15.     {
  16.         // dummy function to test virtual unsafety below
  17.     }
  18.    
  19.     override bool DrawPowerup(int x, int y)
  20.     {
  21.         a = 1; // should work
  22.         b = 2; // should fail
  23.         UnrelatedClass.TestFunc(); // should fail
  24.        
  25.         textureID tx = TexMan.CheckForTexture("M_DOOM", TexMan.TYPE_Any); // should work
  26.         Screen.DrawHUDTexture(tx, 0, 0); // should work
  27.         return true;
  28.     }
  29. }
  30.  
  31. class TestInventory2 : TestInventory
  32. {
  33.     void TestFunc1()
  34.     {
  35.         a = 1; // should work
  36.         b = 2; // should work
  37.     }
  38.  
  39.     // test unsafe inheritance
  40.     override void TestFunc2()
  41.     {
  42.         a = 1; // should work
  43.         b = 2; // should fail
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement