Weird

Published January 22, 2007
Advertisement
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.
Previous Entry Parralaxaxlax
Next Entry Bushes
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement