1 | // emacs edit mode for this file is -*- C++ -*- |
---|
2 | // $Id: ftmpl_factor.h,v 1.2 1997-04-15 10:08:06 schmidt Exp $ |
---|
3 | |
---|
4 | #ifndef INCL_FACTOR_H |
---|
5 | #define INCL_FACTOR_H |
---|
6 | |
---|
7 | /* |
---|
8 | $Log: not supported by cvs2svn $ |
---|
9 | Revision 1.1 1997/03/27 10:30:35 schmidt |
---|
10 | stream-io wrapped by NOSTREAMIO |
---|
11 | |
---|
12 | Revision 1.0 1996/05/17 11:06:32 stobbe |
---|
13 | Initial revision |
---|
14 | |
---|
15 | */ |
---|
16 | |
---|
17 | /*MAKEHEADER*/ |
---|
18 | #include "templates/config.h" |
---|
19 | |
---|
20 | #ifndef NOSTREAMIO |
---|
21 | #include <iostream.h> |
---|
22 | #endif /* NOSTREAMIO */ |
---|
23 | |
---|
24 | |
---|
25 | template <class T> |
---|
26 | class Factor { |
---|
27 | private: |
---|
28 | T _factor; |
---|
29 | int _exp; |
---|
30 | public: |
---|
31 | Factor() : _factor(1), _exp(0) {} |
---|
32 | Factor( const Factor<T> & f ) : _factor(f._factor), _exp(f._exp) {} |
---|
33 | Factor( const T & f, int e ) : _factor(f), _exp(e) {} |
---|
34 | Factor( const T & f ) : _factor(f), _exp(1) {} |
---|
35 | ~Factor() {} |
---|
36 | Factor<T>& operator= ( const Factor<T>& ); |
---|
37 | Factor<T>& operator= ( const T& ); |
---|
38 | T factor() const { return _factor; } |
---|
39 | int exp() const { return _exp; } |
---|
40 | T value() const { return power( _factor, _exp ); } |
---|
41 | Factor<T>& operator+= ( int i ) { _exp += i; return *this; } |
---|
42 | Factor<T>& operator*= ( int i ) { _exp *= i; return *this; } |
---|
43 | Factor<T>& operator*= ( const T & f ) { _factor *= f; return *this; } |
---|
44 | friend int operator== ( const Factor<T>&, const Factor<T>& ); |
---|
45 | #ifndef NOSTREAMIO |
---|
46 | void print ( ostream& ) const; |
---|
47 | #endif /* NOSTREAMIO */ |
---|
48 | }; |
---|
49 | |
---|
50 | #ifndef NOSTREAMIO |
---|
51 | template <class T> |
---|
52 | ostream& operator<< ( ostream & os, const Factor<T> & f ); |
---|
53 | #endif /* NOSTREAMIO */ |
---|
54 | |
---|
55 | #endif /* INCL_FACTOR_H */ |
---|