fun(ppstr, 20); _______ }
´ð°¸£º*array=new mystring(len);£¬(**ppstr).show();»òstr.show();
£Û½âÎö£Ýµ÷ÓÃmystringÀàµÄ¹¹Ô캯Êý¿ª±Ù¿Õ¼ä£¬ºó½øÐÐ×Ö·ûµÄ¸´ÖÆ¡£Êä³ö¿ÉÒÔÖ±½ÓʹÓÃstr»òÕß Ê¹Óöþ¼¶Ö¸Õë¡£
2. ÔÚÏÂÃæ³ÌÐòºáÏß´¦ÌîÉÏÊʵ±×־䣬Íê³ÉÀàµÄ¶¨Òå¡£ class line; class box { private: int color; int upx, upy; int lowx, lowy; public: _________
void set_color (int c){color=c;}
void define_box (int x1, int y1, int x2, int y2) {upx=x1;upy=y1;lowx=x2;lowy=y2;} };
class line { private: int color;
int startx, starty; int endx, endy; public:
friend int same_color(line l,box b); void set_color (int c) {color=c;} void define_line (___________)
{startx=x1;starty=y1;endx=x2;endy=y2;} };
int same_color(line l, box b) {if (l.color==b.color) return 1; return 0; }
´ð°¸£ºfriend int same_color(line l, box b );,int x1, int y1, int x2, int y2
£Û½âÎö£Ý³ÉÔ±º¯Êý×÷ΪÓÑÔªº¯ÊýµÄʹÓá£Ê¹ÓÃfriend¹Ø¼ü×Ö¡£Óɺ¯ÊýÌå¿ÉÖªÐβεÄÀàÐͺ͸öÊý¡£ 3. ÏÂÃæ³ÌÐòÓÃÀ´ÇóÖ±½ÇÈý½ÇÐÎб±ß³¤¶È¡£ #include
Point(double i=0,double j=0) {x=i;y=j;}
Point(Point &p) {x=p.x;y=p.y;} };
class Line {private: Point p1,p2; public:
Line(Point &xp1,Point &xp2):________{} double GetLength(); };
double Line::GetLength() {double dx=p2.x-p1.x; double dy=p2.y-p1.y;
return sqrt(dx*dx+dy*dy); }
void main()
{ Point p1,p2(6,8); Line L1(p1,p2);
cout< ´ð°¸£ºfriend Line;,p1(xp1),p2(xp2) £Û½âÎö£ÝÓÑÔªÀàµÄʹÓ㬶¨ÒåLineÊÇPointÀàµÄÓÑÔªÀ࣬³ÉÔ±¶ÔÏóµÄ³õʼ»¯²ÉÓÃÁбíµÄÐÎʽ¡£ 4. ÔÚÏÂÃæ³ÌÐòµÄµ×»Ïß´¦ÌîÉÏÊʵ±µÄ×־䣬ʹ¸Ã³ÌÐòÖ´Ðнá¹ûΪ40¡£ #include Test (int i=0) {x=i+x;} int Getnum() {return Test::x+7;} }; _______; void main() {Test test; cout< ´ð°¸£ºstatic int x;,int Test::x=30; £Û½âÎö£Ý´Ó³ÉÔ±º¯Êý·ÃÎÊ·½Ê½ÀàÃû£º£º³ÉÔ±¿ÉÖªÊǾ²Ì¬³ÉÔ±ËùÒÔstatic int x;´Ó½á¹ûÒª¶Ô³õʼ »¯Îª30£¬ÇÒÔÚÀàÍâ½øÐгõʼ»¯£¬ int Test::x=30;¡£ 5. ÔÚÏÂÁгÌÐòµÄ¿Õ¸ñ´¦ÌîÉÏÊʵ±µÄ×־䣬ʹÊä³öΪ£º0£¬2£¬10¡£ #include Magic(double d=0.00):x(fabs(d)) {} Magic operator+(______) { return Magic(sqrt(x*x+c.x*c.x)); } _______operator<<(ostream & stream,Magic & c) { stream< void main() {Magic ma;