From: Charles Krug Newsgroups: comp.lang.c++,comp.os.msdos.djgpp Subject: Re: How to implement "They are all Vectors, but different realities?" Date: Thu, 21 Jan 1999 09:55:51 -0500 Organization: Pentek Corporation Lines: 28 Message-ID: <36A73FF7.8B9C1DB2@mail.pentek.com> References: <36A68B87 DOT FFBA110C AT ohriki DOT t DOT u-tokyo DOT ac DOT jp> NNTP-Posting-Host: mail.pentek.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5 [en] (WinNT; U) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Shue-Cheng CHEN wrote: > Hi! > > We know "Force" and "Velocity" are both "Vectors" in mathematics, so > I defined them to own all behaviors and data of Vector (has been defined), > without duplicating the code, as follows, First, look into valarray from the standard library. That should have the Vector functions you need to do vector math. From that, simply use: class Force : public valarray { ; } class Velocity : public valarray } ; } That way, if you attempt to mix Force and Velocity, the compiler will complain. Charles