| Last Modified On : | November 17, 2008 2:40 PM PST |
Rate |
|
Cause:
A virtual function cannot be a static member, since a virtual function call relies on a specific object (base or derived) for determining which function to invoke (note: ISO C++ standard); whereas Static functions are object independent.
Default type of this diagnostic is warning. (Microsoft* Visual C++*'s equivalent warning is C4526.)
Example:
class base {
virtual void foo( int ) = 0;
};
class derived: public base {
static void foo( int ); // generates warning 357
};
>>icl /c t.cpp
Intel(R) C++ Compiler Professional for applications running on IA-32, Version 11
.0 Build 20080916 Package ID: w_cproc_p_11.0.061
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.t.cpp
t.cpp(11): warning #357: only nonstatic member functions may be virtual
static void foo( int );
^
Possible resolution:

English | 中文 | Русский | Français
Grishma Kotecha (Intel)
| ||
Jennifer Jiang (Intel)
|