hi in my text book i have this problem.
how to program this

Define a class Quadratic_int that stores the coefficients of a quadratic polynomial in a dynamically allocated array of integers. Supply the "big three" memory management functions. Use this class to demonstrate 
(a) the difference between initialization 
        Quadratic_int s; 
        Quadratic_int t = s; 
and assignment operation
        Quadratic_int s; 
        Quadratic_int 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 a quadratic function 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 quadratic equation has or has not real roots. Overload the stream operators << and >>. Demonstrate all these functions and operators.

thnx for help

7 Years
Discussion Span
Last Post by sergent

Now, Where's your code? Haven't you tried solving this problem yourself? Post your progress if you've attempted this.. Else, have a go @ it, then come back if u have any problems....


When is the assignment due, that is, how much time do you have before you have to turn it in? Have you studied c++ classes and arrays yet?

Edited by Ancient Dragon: n/a


Since you are reading the book, I assume you have some knowledge, so here is a basic start

class Quadratic_int{
 int *coefficients;
 Quadratic_int(); //default constructor 
 Quadratic_int(const Quadratic_int&) ; //copy constructor[ one of big 3 ]
 ~Quadratic_int(); //destructor[ two of big 3 ]
 Quadratic_int& operator=(const Quadratic_int&); // assignment operator[ three of big 3 ]
 //..possibly more function for quadratic class

Now you need to define the skeleton above. THink about it and start coding. If your stuck, then you aren't thinking, reading, and researching enough.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.