Jump to content
  • Advertisement
  • entries
    743
  • comments
    1924
  • views
    582993

Weird

Sign in to follow this  
Aardvajk

127 views

This is weird:


#include

class x
{
public:
void f(class y &v){ printf("%d\n",sizeof(v)); }
};

class y
{
public:
int x[100];
};

int main()
{
x xv;
y yv;

xv.f(yv);

return 0;
}


Using Digital Mars C++, that produces the correct output of 400. How does that work? I was expecting a "size of wosssname is unknown" error.

Just playing around with some double dispatch ideas and read in a thread about this (class y &v) stuff to forward declare in the actual parameter list, which is handy to know, but I still don't see how the above can compile.

Very strange. Sure someone will explain it.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!