Can a static member function be virtual?
I believe not. But can someone please explain why ?
of course, it can not. The reason is simple: a virtual member function must take an implicit 'this' argument so that the compiler and runtime libraries can resolve the call properly. However, since static member functions don't take a this argument, they can't be virtual. Notice that you can call a static member without even instantiating an object:
As a rule, virtual member functions are called for a specific OBJECT. Static member functions are called for a CLASS and therefore can only access static data members.
Last edited by Danny; 02-21-2004 at 05:18 PM.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL