曾经沧海千秋梦
曾经沧海千秋梦
打倒自己,找回自己----真实的自己.
关注数: 4
粉丝数: 2
发帖数: 38
关注贴吧数: 3
请教一个指针声明问题 //Cat一个类.我误把Cat*const Pointer写成Cat const *Pointer,程序也能运行.请问这这么声明一个指针有没有违规?要是不违规,这么声明的一个指针叫什么针指,请各位帮帮忙,谢谢!!!!!
帮帮忙!我这个程序错在哪里啊????? #include class Point{public:void SetX(int x){itsX=x;}void SetY(int y){itsY=y;}int GetX()const{return itsX;}int GetY()const{return itsY;}private:int itsX;int itsY;};class Poin{public:Poin(int top,int left,int bottom,int right);~Poin(){};int GetTop()const{return itsTop;}int GetLeft()const{return itsLeft;}int GetBottom()const{return itsBottom;}int GetRight()const{return itsRight;}Point GetUpperLeft()const{return itsUpperLeft;}Point GetLowerLeft()const{return itsLowerLeft;} Point GetUpperRight()const{return itsUpperRight;}Point GetLowerRight()const{return itsLowerRight;}void SetTop(int top){itsTop=top;}void SetLeft(int left){itsLeft=left;}void SetBottom(int bottom){itsBottom=bottom;}void SetRight(int right){itsRight=right;}int GetArea()const;private:Point itsUpperLeft;Point itsUpperRight;Point itsLowerLeft;Point itsLowerRight;int itsTop;int itsLeft;int itsBottom;int itsRight;};#include"Poin.hpp"Poin::Poin(int top,int left,int bottom,int right){itsTop=top;itsLeft=left;itsBottom=bottom;itsRight=right;itsUpperLeft.SetX(left);itsUpperLeft.SetY(top);itsUpperRight.SetX(right);itsUpperRight.SetY(top);itsLowerLeft.SetX(left);itsLowerLeft.SetY(bottom);itsLowerRight.SetX(right);itsLowerRight.SetY(bottom);}int Poin::GetArea()const{int Width=itsRight-itsLeft;int Height=itsTop-itsBottom;return (Width*Height);}int main(){Poin MyRectangle(100,20,50,80);int Area=MyRectangle.GetArea();std::cout<<"Area: "<
1
下一页