1.名称空间后
using namespace std;
std::cout<<std::hex<<3.4<<std::endl;
2.类成员函数实现时 表示类的成员函数
base.h中
class base
{
public:
base();
};
base.c中
base :: base(){};
3.引用类中的静态函数数
base.h中
class base
{
public:
static void func(){};
};
函数调用时
int main(void)
{
base::func();//func前面的static关键词并不一定要有,但量func()必须要符合静态函数的特征
return 0;
}
4.引用全局函数,如windows API,实际上相当于调用了一个默认为空的名称空间
mfc程序中:
BOOL MyDlg::OnInitDialog()
{
::MessageBox(this,"text","caption",MB_OK);
return 0;
}
5.在派生类的函数实现时,派生类重载了基类的成员函数,但是又需要使用基类的成员函数
class base
{
protected:
int myfunc(){}
};
class derived
{
protected:
int myfunc(){}
public:
void testfunc();
};
在testfunc()实现时
void derived::testfunc()
{
//使用派生类的函数
myfunc();
//如果使用基类的函数
base::myfunc();
}