This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: polymorphism - virtual memory exhausted
- To: alphonso at isip dot msstate dot edu
- Subject: Re: polymorphism - virtual memory exhausted
- From: Eric Christopher <echristo at cygnus dot com>
- Date: Wed, 22 Nov 2000 13:29:06 -0800
- CC: gcc-bugs at gcc dot gnu dot org
- References: <200011222113.PAA08100@isip108.isip.msstate.edu>
This code is not quite what we need to track down the problem. A
preprocessed .ii file would be better. Use -save-temps on the compile
line to leave one.
-eric
> Sample Code:
> ------------
>
> enum LIST_TYPE { SINGLE = 0, DOUBLE, DEF_LIST_TYPE = DOUBLE };
>
> // virtual class interface
> template<class T>
> class ListBase {
> virtual boolean add() = 0;
> virtual boolean remove(T* obj) = 0;
> ...
> ...
> }
>
> template<class T>
> class List {
>
> // virtual pointer
> ListBase<T>* virtual_lst_d;
>
> // constructor
> List (LIST_TYPE arg = DEF_LIST_TYPE) {
> if (arg == SINGLE) {
> virtual_lst_d = new SingleLinkedList<T>();
> }
> else {
> virtual_lst_d = new DoubleLinkedList<T>();
> }
> }
>
> // call through methods for add
> boolean add() {
> virtual_lst_d->add();
> }
>
> // call through methods for remove
> boolean remove(T* obj) {
> virtual_lst_d->remove(obj);
> }
> ...
> ...
> }
>
> template<class T>
> class SingleLinkedList : public ListBase<T> {
> boolean add();
> boolean remove(T* obj);
> ...
> ...
> }
>
> template<class T>
> class DoubleLinkedList : public ListBase<T> {
> boolean add();
> boolean remove(T* obj);
> ...
> ...
> }
>
> --
> Issac Alphonso <ija1@ece.msstate.edu> <http://www.ece.msstate.edu/>
> Mississippi State University, Mississippi 39762