1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | // emacs edit mode for this file is -*- C++ -*- |
---|
3 | /////////////////////////////////////////////////////////////////////////////// |
---|
4 | #ifndef INCL_CLASS_H |
---|
5 | #define INCL_CLASS_H |
---|
6 | |
---|
7 | // #pragma interface |
---|
8 | |
---|
9 | #ifndef NOSTREAMIO |
---|
10 | #ifdef HAVE_IOSTREAM |
---|
11 | #include <iostream> |
---|
12 | #define OSTREAM std::ostream |
---|
13 | #define ISTREAM std::istream |
---|
14 | #elif defined(HAVE_IOSTREAM_H) |
---|
15 | #include <iostream.h> |
---|
16 | #define OSTREAM ostream |
---|
17 | #define ISTREAM istream |
---|
18 | #endif |
---|
19 | #endif |
---|
20 | |
---|
21 | template <class T> |
---|
22 | class Substitution { |
---|
23 | private: |
---|
24 | T _factor; |
---|
25 | T _exp; |
---|
26 | public: |
---|
27 | Substitution() : _factor(1), _exp(0) {} |
---|
28 | Substitution( const Substitution<T> & f ) : _factor(f._factor), _exp(f._exp) {} |
---|
29 | Substitution( const T & f, const T & e ) : _factor(f), _exp(e) {} |
---|
30 | Substitution( const T & f ) : _factor(f), _exp(1) {} |
---|
31 | ~Substitution() {} |
---|
32 | Substitution<T>& operator= ( const Substitution<T>& ); |
---|
33 | Substitution<T>& operator= ( const T& ); |
---|
34 | T factor() const { return _factor; } |
---|
35 | T exp() const { return _exp; } |
---|
36 | // T value() const { return power( _factor, _exp ); } |
---|
37 | // Factor<T>& operator+= ( int i ) { _exp += i; return *this; } |
---|
38 | // Factor<T>& operator*= ( int i ) { _exp *= i; return *this; } |
---|
39 | // Substitution<T>& operator*= ( const T & f ) { _factor *= f; _exp *= f; return *this; } |
---|
40 | #ifndef NOSTREAMIO |
---|
41 | void print ( OSTREAM& ) const; |
---|
42 | friend OSTREAM& operator<< ( OSTREAM & os, const Substitution<T> & f ) |
---|
43 | { |
---|
44 | f.print( os ); |
---|
45 | return os; |
---|
46 | } |
---|
47 | #endif |
---|
48 | }; |
---|
49 | template <class T> |
---|
50 | int operator== ( const Substitution<T>&, const Substitution<T>& ); |
---|
51 | |
---|
52 | // #ifdef IMPL_CLASS_H |
---|
53 | // #include "class.cc" |
---|
54 | // #endif |
---|
55 | |
---|
56 | #endif /* INCL_CLASS_H */ |
---|
57 | |
---|