Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>// simply for printf
- #include <conio.h>// for _getch();
- class CBaseObject {
- int x, y;
- public:
- int testCount() { return(x-y); }
- void setValues(int,int);
- private:
- static int ID; // integer type ID under private. - part of your test actually.
- static int Count; // integer type count under private. - part of your test actually.
- };
- void CBaseObject::setValues(int a, int b)
- {
- x = a;
- y = b;
- }
- int subtraction(int y, int x)
- {
- static int result; // my static result so i dont' send the address
- result = y-x; // my actual subtraction
- return result; // lets send back the number.
- }
- int main()
- {
- CBaseObject Subtract;//Setup the class pointer.
- Subtract.setValues(10 , 4);//Use the class set value to put the numbers in place.
- printf("Class Style Subtract: %d\n", Subtract.testCount());//run testcount which does the actual subtraction.
- int (* minus)(int,int) = subtraction;//setup function pointer for "subtraction";
- printf("Function Pointer Subtract: %d\n", minus(10, 4));// run my new found "minus" pointer.
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement