Advertisement
bhok

C++ Member Functions

May 25th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. /// More Tutorials at BrandonHok.com
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. class kfcStore
  7. {
  8. public:
  9.     void makeFoodFunction()
  10.     // Do you see the void here? This is a data type. You may google for more information.
  11.     // The datatype before a function's name is called a return type
  12.     {
  13.         //what does the function do? [code here]
  14.         cout << "hamburgers";
  15.         cin.get();
  16.     }
  17.  
  18. }; // end of class
  19.  
  20.  
  21.    // How do we call a function from a class?
  22.    // We have to first create the object and order it to do something
  23.  
  24. int main()
  25. {
  26.     kfcStore objectPopcorn;
  27.     objectPopcorn.makeFoodFunction();
  28.    
  29.         // What did you think happened here?
  30.         // The class kfcStore made the object 'objectPopcorn'
  31.         // Then we told 'objectPopcorn' to call the 'makeFoodFunction' from its class
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement