Carcigenicate

Example

Jan 12th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class numbers {
  6.    
  7.     int value1;
  8.     int value2;
  9.    
  10.     public:
  11.     numbers () {
  12.         value1 = 0;
  13.         value2 = 0;
  14.     }
  15.    
  16.     void set_values (int input1, int input2) {
  17.         value1 = input1;
  18.         value2 = input2;
  19.         cout << "Values set to " << value1 << " and " << value2 << endl;
  20.     }
  21.    
  22.     int add () {
  23.         return value1 + value2;
  24.     }
  25.    
  26.     int multiply () {
  27.         return value1 * value2;
  28.     }
  29.    
  30. };
  31.  
  32. int main () {
  33.     numbers num1, num2;
  34.    
  35.     num1.set_values (1, 3);
  36.     num2.set_values (5, 10);
  37.    
  38.     cout << "num1 Added: " << num1.add () << endl;
  39.     cout << "num1 Multiplied: " << num1.multiply () << endl;
  40.    
  41.     cout << "num2 Added: " << num2.add () << endl;
  42.     cout << "num2 Multiplied: " << num2.multiply () << endl;
  43.    
  44.     cout << "Done \n";
  45. }
Advertisement
Add Comment
Please, Sign In to add comment