C++ question: static
登录 | 论坛导航 -> 华新鲜事 -> 社会百科 | 本帖共有 11 楼,当前显示第 8 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:graduating (等级:4 - 马马虎虎,发帖:562) 发表:2003-06-05 10:10:24  8楼 
I saw your problem. But I don't think that's thepoint. I compiled the following code using g++ version 2.95.2 on Solaris: class Object { private: typedef void (Object::*Omf)(); /*static*/ Omf farray[3]; }; Compilation gave no error. I suppose the error was caused by other factors.
Other source of error?
Flying, i investigate it again. I think the problem may caused by the initialization of farray.

In the public part, i defined some public functions, and i initialize the farray with these public functions.

Class Object
{
public:
void retrieve() {...}
void insert() {...}
void update() {...}

private:
typedef void (Object::*Omf)();
Omf farray[3];
};

Object::Omf Object::farray[3]=
{
&Object::retrieve, &Object::insert, &Object::update
};

&Object::retrieve and such are fixed addresses, so farray must be defined as static, correct? Is this a rule defining a static member?
What are the rules for definition of static members?

TIA
Never frown even though tomorrow may be grey, may be blue
Who knows who will love your smile in next minute
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 11 楼,当前显示第 8 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码