Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- behav MyBehav // declaring a behaviour
- {
- void TestMe ()
- {
- printf ("Tested!\n");
- }
- };
- float behav // extending a primitive with a behaviour
- {
- behav MyBehav; // reusing a behaviour
- float Zero (float *this)
- {
- return (*this = 0);
- }
- };
- struct Vector_s
- {
- int x, y, z;
- behav MyBehav; // reusing a behaviour
- behav // declaring an anonymous behaviour
- {
- void Print (struct Vector_s *);
- }
- };
- float x = 5;
- struct Vector_s v;
- MyBehav.TestMe ();
- x.MyBehav.TestMe ();
- x.Zero ();
- float.Zero (&x);
- v.MyBehav.TestMe ();
- v.Print ();
- Vector_s.Print (&v);
- void Vector_s.Print (struct Vector_s *)
- struct Vector_s *this;
- {
- printf ("%i, %i, %i\n", this->x, this->y, this->z);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement