static函数:类里面的static和函数指针的特殊事项



# <iostream>
using std;
pr {
cout << "YYYYYYYYY\n";
}
tt{
public:
(*pp);
*p;
v {
this->pp; // can be ivoked by this ,but ......
}
vv {
// this -> pp; No , _disibledevent=> *tt::p = NULL; //must 1. * 2. tt:: and 3. p
{
tt a;
a.pp;
(*tt::pp);
cout << (tt) << endl; //1
}
# <iostream>
using std;
void pr {
cout << "asdf\n";
}
tt{
public:
void (*p) ;
tt {
p = &(::pr);
}
a {
cout << "aaaaa function!\n";
}
};
typedef (tt::*MM) ;
{
cout << (tt) << endl; //4 not 1, void *p in tt is a val, not a function! so is 4
tt a;
a.p;
cout << &tt::a << endl;
//cout << ( )& a.a << endl;
MM myf = &tt::a;
(a.*myf); //like this
}
# <iostream>
using std;
tt {
public:
a;
};
tt::a = 10;
{
cout << (tt) << endl; //1, , no matter it is const or poer or reference! save in section, not
//scope!
cout << tt::a << endl;
}
# <iostream>
using std;
tt {
public:
double a;
char b;
virtual _a {}
virtual _b {}
};
{
cout << (tt) << endl; //Linux 16, Windows 24, and vptr in the beginning !
//but align of windows is 8,because of the double,but align of the Linux is 4,even
//u use #pragma pack(8), the align is still 4 BYTE!
}
# <iostream>
using std;
T{
public:
char aa;
double i;
virtual a {}
};
{
//cout << &(((T *)1)->aa) << endl; //can use it in Windows! LInux : can't
//get the aa's addr, to get that the vptr is
// at the beginning or the end of the or the object!
T *a = T;
cout << ()&(a->aa) << endl;
cout << ()a << endl;


cout << (T) << endl;
delete a;
}

其实些很变态使用操作都在上面了这里仅仅是些很少用到东西注意拉!
Tags:  函数指针 函数内static static成员函数 static函数

延伸阅读

最新评论

发表评论