Annotation of researchv10no/cmd/cfront/ooptcfront/demo/override.c, revision 1.1

1.1     ! root        1: #include "check.h"
        !             2: 
        !             3: // check overriding of member functions
        !             4: 
        !             5: 
        !             6: template <class T> class oc {
        !             7: public:
        !             8:   T mem ;
        !             9:   // a vanilla function
        !            10:   foo() ;
        !            11:   // an operator
        !            12:   operator + (oc) ;
        !            13:   // a constructor
        !            14:   oc() ;
        !            15: } ;
        !            16: 
        !            17: // default class definitions
        !            18: template <class T> oc<T>::foo() {return 1;}
        !            19: template <class T> oc<T>::oc() {mem = 1;}
        !            20: template <class T> oc<T>::operator + (oc<T>) {return 1;}
        !            21: 
        !            22: // override them with the real definitions, for int instantiations
        !            23: oc<int>::foo() {return 2;}
        !            24: oc<int>::operator + (oc<int>) {return 2;}
        !            25: 
        !            26: oc<int>::oc() {mem = 2 ;}
        !            27: 
        !            28: oc<double> ocd ;
        !            29: oc<int> oci ;
        !            30: 
        !            31: 
        !            32: // *****************************
        !            33: 
        !            34: 
        !            35: main () {
        !            36:   start_test(__FILE__) ;
        !            37: 
        !            38:   check(ocd.foo() == 1) ;
        !            39:   check((ocd + ocd) == 1) ;
        !            40:   check(ocd.mem == 1) ;
        !            41:   
        !            42:   check(oci.foo() == 2) ;
        !            43:   check((oci + oci) == 2) ;
        !            44:   check(oci.mem == 2) ;
        !            45:   
        !            46:   end_test() ;
        !            47: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.