| November 16, 2008 12:00 AM PST | |
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:
- Remove the static qualifier.
- Rename the static function name in derived class, i.e. rename "foo" to "bar".
This article applies to: Intel® C++ Compiler for Linux* Knowledge Base, Intel® C++ Compiler for Mac OS X* Knowledge Base, Intel® C++ Compiler for Windows* Knowledge Base, Intel® Parallel Composer Knowledge Base
For more complete information about compiler optimizations, see our Optimization Notice.
Comments (0) 
Trackbacks (0)
Leave a comment 
Grishma Kotecha (Intel)
| ||
Jennifer Jiang (Intel)
|

