• entries
    743
  • comments
    1924
  • views
    579161

Weird

Sign in to follow this  
Aardvajk

86 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