this is what I am working on
  #include <iostream>
   
  int add (int x, int y) {
      int z;          
      z = x + y;
      return (z);     
  }
   
  int sub (int x, int y) {
      int z;          
      z = x - y;
      return (z);     
  }
   
  int multi (int x, int y) {
      int z;          
      z = x * y;
      return (z);     
  }
   
  int div (int x, int y) {
      int z;          
      z = x / y;
      return (z);     
  }
   
  main ()
  {
  int i, j, k1, k2, k3, k4;
  i = 10;
  j = 20;
  k1 =  + (i, j);    
  k2 =  -  (i, j);
  k3 =  *  (i, j);
  k4 =  /   (i, j);          
       cout("The result of k1, k2, k3 ,k4 is:   \n", k1, k2, k3, k4);  
  }
   


Thomas Hruska <[EMAIL PROTECTED]> wrote:          Robert Ryan wrote:
> actually, i am trying to get this done in C++. I should have made this in 
> C++, what was i thinking
>> [email protected] wrote:
>>> #include <stdio.h>
>>>
>>> int add (int x, int y) {
>>> int z; 
>>> z = x + y;
>>> return (z); 
>>> }
>>> main ()
>>> {
>>> int i, j, k;
>>> i = 10;
>>> j = 20;
>>> k = add(i, j); 
>>> printf ("The value of k is %d\n", k); 
>>> }
>>> how do you change the above code to the following 
>>>
>>> + (2, 6)
>>> - ( 2, 6)

Assuming you mean that you want to do something like:

k = operator+(2, 6);

Adding two 'int's is a primitive operation. You can't overload 
operators for primitives. That's an ANSI C++ Standard restriction.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task. Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/



                         

       
---------------------------------
Yahoo! oneSearch: Finally,  mobile search that gives answers, not web links. 

[Non-text portions of this message have been removed]

Reply via email to