source: git/factory/templates/ftmpl_factor.h @ 9d3636

spielwiese
Last change on this file since 9d3636 was d2b5a7, checked in by Wilfred Pohl <pohl@…>, 26 years ago
* ftmpl_factor.h (template <class T> class Factor): `operator == ( const Factor<T> &, const Factor<T> &)' removed as friend and added as extra operator git-svn-id: file:///usr/local/Singular/svn/trunk@2048 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: ftmpl_factor.h,v 1.5 1998-06-03 14:51:33 pohl Exp $ */
3
4#ifndef INCL_FACTOR_H
5#define INCL_FACTOR_H
6
7#include <factoryconf.h>
8
9#ifndef NOSTREAMIO
10#include <iostream.h>
11#endif /* NOSTREAMIO */
12
13
14template <class T>
15class Factor {
16private:
17    T _factor;
18    int _exp;
19public:
20    Factor() : _factor(1), _exp(0) {}
21    Factor( const Factor<T> & f ) : _factor(f._factor), _exp(f._exp) {}
22    Factor( const T & f, int e ) : _factor(f), _exp(e) {}
23    Factor( const T & f ) : _factor(f), _exp(1) {}
24    ~Factor() {}
25    Factor<T>& operator= ( const Factor<T>& );
26    Factor<T>& operator= ( const T& );
27    T factor() const { return _factor; }
28    int exp() const { return _exp; }
29    T value() const { return power( _factor, _exp ); }
30    Factor<T>& operator+= ( int i ) { _exp += i; return *this; }
31    Factor<T>& operator*= ( int i ) { _exp *= i; return *this; }
32    Factor<T>& operator*= ( const T & f ) { _factor *= f; return *this; }
33#ifndef NOSTREAMIO
34    void print ( ostream& ) const;
35#endif /* NOSTREAMIO */
36};
37
38template <class T> int
39operator== ( const Factor<T>&, const Factor<T>& );
40
41#ifndef NOSTREAMIO
42template <class T>
43ostream& operator<< ( ostream & os, const Factor<T> & f );
44#endif /* NOSTREAMIO */
45
46#endif /* ! INCL_FACTOR_H */
Note: See TracBrowser for help on using the repository browser.