Topic: Pure virtual static class members
Author: Don Organ <organ@ltx-tr.com>
Date: 1997/03/21 Raw View
Mike Duigou wrote:
>
> I (and another person who independently ran into this less than a week
> after I did) were wondering why the current C++ spec explicitly prohibits
> virtual and more importantly pure virtual static member functions?
There was an extended thread on the topic of static virtuals in this
(or a related) newsgroup about two years ago. My conclusion was that
there was no technical reason why C++ could not support static virtual
member functions. However, to add support would require dis-ambiguating
the "&" operator between a pointer to a member function or a pointer to
a static function. There was very little support on the newsgroup for
any such change at that time, and work-arounds exist that require
limited extra coding. (I submitted a formal comment during the public
comment period that was open at that time, but received no response -
I've since changed companies so maybe the e-mail was lost.)
-DVO-
==============================================
Don Organ (408) 383-2518 organ@ltx-tr.com
LTX Corp. 3930 N. First St. San Jose, CA 95134
==============================================
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: MIKE_DUIGOU@fwb.com (Mike Duigou)
Date: 1997/03/07 Raw View
I (and another person who independently ran into this less than a week
after I did) were wondering why the current C++ spec explicitly prohibits
virtual and more importantly pure virtual static member functions?
The case I came up with for this feature was functions which returned
"newed" objects of the requested class. The functions have to be static so
I can do something like
ObjectMakerFuncs MyClasses [] =
{
ClassA::MakeOne,
ClassB::MakeOne,
ClassC::MakeOne
}
Later, some scheme is used to select which item in the array is called when
an object is required. "New by Name", SOM, dynamic binding, persitance,
etc. are all way too much overkill for this situation. All I want is to
ensure that the MakeOne static member function of each sub-class is
defined.
Mike Duigou
FWB Software LLC.
--
"Me, when I have nothing to say, my lips are sealed." -- Talking Heads
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1997/03/07 Raw View
MIKE_DUIGOU@fwb.com (Mike Duigou) writes:
> I (and another person who independently ran into this less than a week
>after I did) were wondering why the current C++ spec explicitly prohibits
>virtual and more importantly pure virtual static member functions?
This has been discussed at length in this newsgroup on prior occaisions.
Try searching for the following
comp.std.c++ "virtual static"
comp.std.c++ "static virtual"
using dejanews <http://www.dejanews.com>
(you'll need to select the "Old" database).
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1997/03/11 Raw View
Mike Duigou wrote:
>
> I (and another person who independently ran into this less than a week
> after I did) were wondering why the current C++ spec explicitly prohibits
> virtual and more importantly pure virtual static member functions?
>
> The case I came up with for this feature was functions which returned
> "newed" objects of the requested class. The functions have to be static so
> I can do something like
>
> ObjectMakerFuncs MyClasses [] =
> {
> ClassA::MakeOne,
> ClassB::MakeOne,
> ClassC::MakeOne
> }
>
> Later, some scheme is used to select which item in the array is called when
> an object is required. "New by Name", SOM, dynamic binding, persitance,
> etc. are all way too much overkill for this situation. All I want is to
> ensure that the MakeOne static member function of each sub-class is
> defined.
You can't anyway, even with a normal member pure virtual function.
(You want to ensure it is overiden in *each* non-abstract subclass,
not that there is some definition which you can call in each class.)
Why don't you use a ptr to member function ?
I'm not sure I fully understand what you want to do.
--
Valentin Bonnard
mailto:bonnardv@pratique.fr
http://www.pratique.fr/~bonnardv (Informations sur le C++ en Francais)
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]