Hello.
Please if somebody has the time and willingness to do this program in C++ I would be very happy and grateful.

Define a class Cubic that stores the coefficients of a polynomial of degree 3 in a dynamically allocated array of doubles. Supply the "big three" memory management functions. Use this class to demonstrate
(a) the difference between initialization
Cubic s;
Cubic t = s;
and assignment operation
Cubic s;
Cubic t;
s = t;
(b) the fact that all constructed objects are automatically destroyed
(c) the fact that the copy constructor is invoked if an object is passed by value to a function
(d) the fact that the copy constructor is not invoked when a parameter is passed by reference
(e) the fact that the copy constructor is used to copy a return value to the caller.
Supply a member function which calculates the value of the polynomial for a given argument value. Overload + and - operators for addition and subtraction of two polynomials and the unary operator * which return true or false when the corresponding cubic function has or has not critical points. (We say that a function f(x) has a critical point z when its derivative has value null at this point, i.e. f '(z) = 0.) Overload the stream operators << and >>. Demonstrate all these functions and operators.

Recommended Answers

All 5 Replies

No one is going to your homework for you! Can someone put a sticky next to the "Read This Before Posting" sticky that explains not to post homework questions like this!?

Dave

how about you try yourself first and the post what you have. I do all my work myself and you should too....lazy. Nothing gets handed to you unless you pay money.

I am not obligating anybody...

OK, then, let's try from another angle. Can you help with clarification of the task itself. It sounds... strange. The coefficients of a polynomial of degree 3 - this should be a,b,c,d from a.x^3+b.x^2+c.x+d, right? And what is it meant by dynamically allocated array. And what "big three"?

Dynamic Memory Allocation

I have no idea what is the "big three" but I guess it's the constructor of the class, the destructor and the assignment operator =.

Class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.