Can I pass this as any argument? Why cant we do something like the
following?.
// main.cpp
int main()
{
extern ABCD *abcd;
ABCD::func(abcd, 3);
}
//abcd.h
struct ABCD
{
void func(int i);
}
Because that isn't the syntax.
To do what you appear to want to do you could use
abcd->func(3);
to call the member function.
Note that while it is sometimes useful to think of the "this" parameter
as just an extra hidden parameter, the standard does not require that it
be passed in the same manner as a regular parameter, and I do know of
compilers where "this" was passed to member functions differently than
an ordinary parameter to a function. The designer of the compiler
figured that the member function likely did a number of accesses to the
member being passed, so this was passed in a register designed for
indexed access of a block of memory, while ordinary parameters will
passed via the stack.