Thread: Small question , can you help me ??

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    3

    Smile Small question , can you help me ??

    Hi for ever

    I am asking about :

    How to addition two object with different type and then store the result in the object have same type of one of these two object
    by using operator overloading ?

    for example :

    we have class called ThreeD

    Code:
    ThreeD operator +(ThreeD op1, ThreeD op2) 
      { 
        ThreeD result = new ThreeD(); 
     
        /* This adds together the coordinates of the two points 
           and returns the result. */ 
        result.x = op1.x + op2.x;  
        result.y = op1.y + op2.y;  
        result.z = op1.z + op2.z;  
     
        return result; 
      }
    in these example we add two object of same type in the same class

    What about if I have two classes
    and I wanted to add object from class 1 to object from class 2
    and then store the result in objcet of type of class 1


    Thats all ,
    thanks to reed my question ,
    I wait the answer
    Last edited by Salem; 12-19-2008 at 10:57 AM. Reason: Pointless font abuse removed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  2. Hi all, I have a small question...
    By Pandora in forum Windows Programming
    Replies: 3
    Last Post: 03-16-2003, 06:21 AM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  4. A small Question
    By CodeJerk in forum C++ Programming
    Replies: 2
    Last Post: 11-20-2002, 09:08 AM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM