home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!think.com!spool.mu.edu!umn.edu!news.orst.edu!belar.ECE.ORST.EDU!gnk
- From: gnk@belar.ECE.ORST.EDU (Giri Rangan)
- Subject: Multiple representation of an object type
- Message-ID: <BxDGKn.4u2@news.orst.edu>
- Sender: usenet@news.orst.edu
- Nntp-Posting-Host: belar.ece.orst.edu
- Organization: none
- Date: Sun, 8 Nov 1992 00:41:08 GMT
- Lines: 28
-
- Hi,
-
- I am in search of a correct and a very efficient way of implementing
- multiple representations of an object type. Here is an example :
-
- I have a polynomial class. A polynomial can be represented in two ways.
- One is to store the coefficients of each order term and the other way
- is to store the roots of the polynomial. Both the representations are
- useful and required, especially since my variable is a complex
- quantity ('z'). Hence, the coefficient representation is useful while
- doing addition and subtraction of polynomials while the roots
- representation is useful while doing multiplication or division.
-
- Another point to note is that the two representations are inter
- convertible. As a result, if I change a particular coefficient, then
- the present roots of the polynomial are no longer valid. They will have
- to change too.
-
- So how are such class types normally implemented ? I feel my present
- way of implementation is rather messy.
-
- Please mail to :
- gnk@aldur.ece.orst.edu
- --
- =================================================================
- Giri NK Rangan
- Dept of ECE, Oregon State University, Corvallis, OR 97331.
- =================================================================
-