Guest User

Untitled

a guest
Nov 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. /*20.If a method cannot be inline, if you do not want it to be
  2. inline or if you want the class definition contain the minimum of
  3. information, then you must just put the prototype of the method
  4. inside the class and define the method below the class: */
  5.  
  6.  
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. class vector
  11. {
  12. public:
  13.  
  14. double x;
  15. double y;
  16.  
  17. double surface(); // The ; and no {} shows it is a prototype
  18. };
  19.  
  20. double vector::surface()
  21. {
  22. double s = 0;
  23.  
  24. for (double i = 0; i < x; i++)
  25. {
  26. s = s + y;
  27. }
  28.  
  29. return s;
  30. }
  31.  
  32. int main ()
  33. {
  34. vector k;
  35.  
  36. k.x = 4;
  37. k.y = 5;
  38.  
  39. cout << "Surface: " << k.surface() << endl;
  40.  
  41. return 0;
  42. }
Add Comment
Please, Sign In to add comment