how to call the member function?( C++ ) . or ->

// Declare a new object of type Point.
   Point ptOrigin;

   // Member function calls use the . member-selection operator.
   ptOrigin.SetX( 0 );
   ptOrigin.SetY( 0 );

   // Declare a pointer to an object of type Point.
   Point *pptCurrent = new Point;
   // Member function calls use the -> member-selection operator.
   pptCurrent->SetX( ptOrigin.GetX() + 10 );
   pptCurrent->SetY( ptOrigin.GetY() + 10 );


 
 
 

  X xobj;
  xobj.set_i(11);
  xobj.print_i();

  // static data members and functions belong to the class and
  // can be accessed without using an object of class X
  X::print_si();
  X::set_si(22);
  X::print_si();

Technorati : . or ->

posted on 2010-02-05 14:30  jerry data  阅读(133)  评论(0编辑  收藏  举报