Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <iostream>// simply for printf
  3. #include <conio.h>// for _getch();
  4.  
  5. class CBaseObject {
  6.     int x, y;
  7. public:
  8.     int testCount() { return(x-y); }
  9.     void setValues(int,int);
  10.  
  11. private:
  12.     static int ID;  // integer type ID under private. - part of your test actually.
  13.     static int Count; // integer type count under private. - part of your test actually.
  14. };
  15.  
  16. void CBaseObject::setValues(int a, int b)
  17. {
  18.     x = a;
  19.     y = b;
  20. }
  21.  
  22. int subtraction(int y, int x)
  23. {
  24.     static int result; // my static result so i dont' send the address
  25.     result = y-x; // my actual subtraction
  26.     return result; // lets send back the number.
  27. }
  28.  
  29. int main()
  30. {
  31.     CBaseObject Subtract;//Setup the class pointer.
  32.     Subtract.setValues(10 , 4);//Use the class set value to put the numbers in place.
  33.     printf("Class Style Subtract: %d\n", Subtract.testCount());//run testcount which does the actual subtraction.
  34.  
  35.     int (* minus)(int,int) = subtraction;//setup function pointer for "subtraction";
  36.     printf("Function Pointer Subtract: %d\n", minus(10, 4));// run my new found "minus" pointer.
  37.     _getch();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement