Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct Texture
- {
- int GetWidth() const;
- int GetHeight() const;
- };
- struct _Texture
- {
- int width;
- int height;
- _Texture()
- {
- printf("ctor %p\n", this);
- }
- ~_Texture()
- {
- printf("dtor %p\n", this);
- }
- };
- int Texture::GetWidth() const
- {
- return ((_Texture*)this)->width;
- }
- int Texture::GetHeight() const
- {
- return ((_Texture*)this)->height;
- }
- Texture* CreateTexture(int width, int height)
- {
- _Texture* t = new _Texture;
- t->width = width;
- t->height = height;
- return (Texture*)t;
- }
- void DeleteTexture(Texture* texture)
- {
- _Texture* t = (_Texture*)texture;
- delete t;
- }
- int main()
- {
- Texture* t = CreateTexture(320, 240);
- printf("%i x %i\n", t->GetWidth(), t->GetHeight());
- DeleteTexture(t);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement