Problem in calling an overloaded operator= from inside anotheroverloaded operator= in C++

Discussion in 'C++' started by Afshin, Aug 12, 2011.

  1. Afshin

    Afshin Guest

    Hi everybody,

    I am developing code for a scheduling problem in which I have a
    class for products (called cProduct) which contains, among others, an
    array of class cResource to represent the resources used to process
    the product. For both classes (cProduct and cResource), I have defined
    overloaded operator= ; with operator= for cResource being called from
    inside the overloaded operator= defined for cProduct. The problem is
    that in calling the internal operator= (from inside the opertor= for
    class
    cProduct) the value of rhs (being passed from internal call to
    operator=) seems to get lost!.
    I appreciate any hint or clue on how to fix this problem. Below is a
    summary of
    relevant classes and overloaded operator=:

    class cResource{
    public:
    cResource(); //constructor
    int x; //as a sample member variable
     
    Afshin, Aug 12, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. matt p
    Replies:
    3
    Views:
    475
    =?ISO-8859-15?Q?Juli=E1n?= Albo
    Nov 7, 2004
  2. Vinu
    Replies:
    6
    Views:
    471
    Jonathan Mcdougall
    Jul 12, 2005
  3. John Goche
    Replies:
    2
    Views:
    348
    Frederick Gotham
    Sep 4, 2006
  4. Afshin
    Replies:
    0
    Views:
    294
    Afshin
    Aug 12, 2011
  5. Afshin
    Replies:
    7
    Views:
    441
    Victor Bazarov
    Aug 16, 2011
Loading...

Share This Page