Advertisement
apl-mhd

OOP static function

May 13th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. class diy{
  9.    
  10.    
  11.    
  12.     public:
  13.         string name;
  14.         int id;
  15.        
  16.     void loop(int n);
  17.    
  18.     static void display(){  
  19.         /*static function must be in public*/
  20.         /*static function call without object create*/
  21.        
  22.         cout<<"amar sonar banagla";
  23.         }
  24. };
  25.  
  26.  
  27. void diy::loop(int n){
  28.        
  29.         for(int i=0; i<n; i++)
  30.             cout<<n<<" ";
  31.     cout<<"\n";
  32. }
  33.    
  34.  
  35.  
  36. int main(int argc, char **argv)
  37. {
  38.     diy :: display();
  39.    
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement