GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Oct-2005, 14:16
jake_jeckel's Avatar
jake_jeckel jake_jeckel is offline
New Member
 
Join Date: Oct 2005
Posts: 9
jake_jeckel is on a distinguished road

polynomial program


I have to make a polynomial program that can add, subtract and multiply.

I'm asked to make the following functions:
add
An arithmatic addition operation that adds one instance of Polynomial to another.

subtract
An arithmatic subtraction operation that subtracts one instance of Polynomial by another.

multiply
An arithmatic multiplication operation that multiplies one instance of Polynomial by another.

multiply
An arithmatic multiplication operation that multiplies an instance of Polynomial by an integer.

raiseDegree
An arithmatic multiplication operation that multiplies an instance of Polynomial by a polynomial of the form xk for some non-negative integer k.

The thing I am having trouble with is this next part:
The add, subtract, raiseDegree and the two multiply operations should be implemented as void member functions that mutate the contents of the target Polynomial instance.

I have a Polynomial class and the above functions are member functions of this Polynomial. A polynomial instance is basically composed of an array with the index representing the power of x.

I'm just confused on what it is telling me to do. I would rather just have the functions return an instance of a polynomial but it's not what it's asking me to do.

It doesn't seem effective to pass 3 instances of the Polynomial class (first 2 being the two instances being added together and the 3rd which will end up being the sum of the two instances). I am quite sure this isn't what is expected...anyone have any suggestions?

I am writing in c++ by the way.

**
maybe i am to pass just one of the instances of polynomial to be added, and another to store the sum
Therefore my function would look like this:

CPP / C++ / C Code:
void add(const Polynomial& poly2, Polynomial& poly3)
{
   // code to add the current polynomial instance and poly2 and store it into poly3
}

and then use it like this:
CPP / C++ / C Code:
int main () {
Polynomial poly1, poly2, poly3;

poly1.add(poly2, poly3);
// then the poly3 instance should be the sum of poly1 and poly2
}

that's my best guess...but i'd rather get a lil more direction/confirmation.
 
 

Recent GIDBlogToyota - 2008 August Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is my program coded well? dave88 C Programming Language 6 14-Oct-2005 09:18
Type casts ? kai85 C++ Forum 12 23-Jun-2005 12:04
[TUTORIAL] Calling an external program in C (Linux) dsmith C Programming Language 4 22-Apr-2005 13:30
fltk-2.0 cvs Plumb FLTK Forum 20 13-Nov-2004 07:10
Need help with a C program (Long) McFury C Programming Language 3 29-Apr-2004 20:06

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:35.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.