FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
December 01, 2002

Adaptable-Size Classes

(Page 4 of 4)
December 2002/Adaptable-Size Classes/Listing 1

Listing 1: Required boilerplate code for attribute class A_

template <class Parent>
struct A_: public Parent {
    template <class T>
    A_(const T & t_): Parent(t_)
    {
        t_.set(this->a, A_<Unique_>());
    }
    
    template <class T>
    A_ & operator=(const T & t_)
    {
        Parent::operator=(t_);
        t_.set(this->a, A_<Unique_>());
        
        return *this;
    }
    
    template <class T>
    void set(double & t_, T t) const {
        Parent::set(t_, t);
    }        
    void set(double & a, A_<Unique_>) const
    {
         a = this->a;
    }    
    A_() {}
    
    double a;
};
— End of Listing —
Previous Page | 1 | 2 | 3 | 4
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK