⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 point.cpp

📁 c++模板小实验
💻 CPP
字号:
#include<iostream.h>

class point 
{public:
double x;
 double y;
 point(double a=0,double b=0)
 { x=a;
   y=b;
   
 
 }
 void print()
 {cout<<"the original point is("<<x<<","<<y<<")"<<endl;}
public:
	point operator++();
	point operator++(int);
	point operator--();
	point operator--(int);
	void display();
	
	

};

point point::operator ++(int)
{ point t;
  //t.x=x;
  //t.y=y;
 t.x=x++;
 t.y=y++;
cout<<"p++:original x="<<x<<"  ";
cout<<"originai y="<<y<<"   ";
cout<<"x="<<t.x<<"  ";
 cout<<"y="<<t.y<<endl;
cout<<"\n";
 
 return t;

}

point point::operator ++( )
{point t;
//t.x=x;
//t.y=y;

 t.x=++x;
 t.y=++y;
cout<<"++p:original x="<<x<<"  ";
cout<<"originai y="<<y<<"   ";
cout<<"x="<<t.x<<"  ";
 cout<<"y="<<t.y<<endl;
cout<<"\n";
 return t;


}

point point::operator --(int )
{point t;
t.x=x--;
t.y=y--;
cout<<"p--:original x="<<x<<"  ";
cout<<"originai y="<<y<<"   ";
cout<<"x="<<t.x<<"  ";
 cout<<"y="<<t.y<<endl;
cout<<"\n";
return t;

}

point point::operator --( )
{point t;
t.x=--x;
t.y=--y;
cout<<"--p:original x="<<x<<"  ";
cout<<"originai y="<<y<<"   ";
cout<<"x="<<t.x<<"  ";
 cout<<"y="<<t.y<<endl;
 cout<<"\n";

return t;


}

//void point::display()
//{
//	cout<<"x="<<x<<"  ";
 //cout<<"y="<<y<<endl;

//}

void main()
{point p(1,1);
  p.print();

  
	 p++;
 //p.display();
  
	 ++p;
 //p.display();
  
	 p--;
 //p.display();
  
 --p;
 //p.display();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -