ÔÆÌ⺣ - רҵÎÄÕ·¶ÀýÎĵµ×ÊÁÏ·ÖÏíÆ½Ì¨

µ±Ç°Î»ÖãºÊ×Ò³ > Î÷°²Ê¯ÓÍ´óѧ´ó¶þ£¨ÉÏ£©C++ÃæÏò¶ÔÏó³ÌÐòÉè¼Æ¿Î¼þ¸÷ÕÂϰÌâ

Î÷°²Ê¯ÓÍ´óѧ´ó¶þ£¨ÉÏ£©C++ÃæÏò¶ÔÏó³ÌÐòÉè¼Æ¿Î¼þ¸÷ÕÂϰÌâ

  • 62 ´ÎÔĶÁ
  • 3 ´ÎÏÂÔØ
  • 2025/6/25 14:35:33

{ Car myCar;

SportsCar mySportsCar; int c = 5; float d = 5.0; myCar.f(c); mySportsCar.f(c); mySportsCar.f(d); mySportsCar.d();

}

³ÌÐòÔĶÁºÍÉè¼ÆÌ⣺

9.17 ÔĶÁ³ÌÐò£¬¸ø³öÔËÐнá¹û£º £¨1£©

#include \class A {

private: int a,b; public:

A(int i,int j) { a=i; b=j;

}

void move(int x,int y) { a+=x; b+=y; }

void show() { cout<

};

class B: private A {

private:

29

int x,y;

public:

B(int i,int j,int k,int l):A(i,j) { x=k; y=l;

}

void show() { cout<

void fun() { move(2,4);

}

void f1() { A::show(); }

};

void main() { A a1(10,10); a1.show(); B b1(5,5,6,6); b1.fun(); b1.show(); b1.f1(); }

2£©

#include class Point { int x,y; public: Point(int x1=0, int y1=0) :x(x1), y(y1) { cout<<\

}

~Point() {

30

£¨

cout<<\

}

};

class Circle { Point center; //Ô²ÐÄλÖÃ

int radius; //°ë¾¶

public: Circle(int cx,int cy, int r):center(cx,cy),radius(r) { cout<<\

}

~Circle() {cout<<\

};

void main() {

Circle c(3,4,5); }

3£©

#include #include class Point { int x,y; public: Point(int x1=0, int y1=0) :x(x1), y(y1) { cout<<\

}

~Point() { cout<<\

}

};

class Text {

char text[100]; //ÎÄ×ÖÄÚÈÝ public:

Text(char * str) { strcpy(text,str); cout<<\ }

~Text() {cout<<\

};

31

£¨

class CircleWithText : public Point,public Text { public: };

void main() { }

CircleWithText cm(3,4,\

CircleWithText(int cx,int cy, char *msg): Point(cx,cy),Text(msg) { }

~CircleWithText() {cout<<\

cout<<\

£¨4£©

#include class Date { public:

void SetDate(int y,int m,int d){ Year=y; Month=m; Day=d; } void PrintDate(){ cout<

Date(int y,int m,int d){SetDate(y,m,d);} protected:

int Year,Month,Day; };

class Time { public:

void SetTime(int h,int m,int s){ Houre=h; Minutes=m; Seconds=s;} void PrintTime()

{ cout<

Time(int h,int m,int s){SetTime(h,m,s);} protected:

int Houre, Minutes, Seconds; };

class Date_Time: public Date, public Time { public:

32

  • ÊÕ²Ø
  • Î¥¹æ¾Ù±¨
  • °æÈ¨ÈÏÁì
ÏÂÔØÎĵµ10.00 Ôª ¼ÓÈëVIPÃâ·ÑÏÂÔØ
ÍÆ¼öÏÂÔØ
±¾ÎÄ×÷Õߣº...

¹²·ÖÏí92ƪÏà¹ØÎĵµ

Îĵµ¼ò½é£º

{ Car myCar; SportsCar mySportsCar; int c = 5; float d = 5.0; myCar.f(c); mySportsCar.f(c); mySportsCar.f(d); mySportsCar.d(); } ³ÌÐòÔĶÁºÍÉè¼ÆÌ⣺ 9.17 ÔĶÁ³ÌÐò£¬¸ø³öÔËÐнá¹û£º £¨1£© #include \class A { private: int a,b; public: A(int i,int j) { a=i; b=j; } void move(int x,int y) { a+=x; b+=y; } void show() { co

¡Á ÓοͿì½ÝÏÂÔØÍ¨µÀ£¨ÏÂÔØºó¿ÉÒÔ×ÔÓɸ´ÖƺÍÅŰ棩
µ¥Æª¸¶·ÑÏÂÔØ
ÏÞÊ±ÌØ¼Û£º10 Ôª/·Ý Ô­¼Û:20Ôª
VIP°üÔÂÏÂÔØ
ÌØ¼Û£º29 Ôª/Ô ԭ¼Û:99Ôª
µÍÖÁ 0.3 Ôª/·Ý ÿÔÂÏÂÔØ150·Ý
ȫվÄÚÈÝÃâ·Ñ×ÔÓɸ´ÖÆ
VIP°üÔÂÏÂÔØ
ÌØ¼Û£º29 Ôª/Ô ԭ¼Û:99Ôª
µÍÖÁ 0.3 Ôª/·Ý ÿÔÂÏÂÔØ150·Ý
ȫվÄÚÈÝÃâ·Ñ×ÔÓɸ´ÖÆ
×¢£ºÏÂÔØÎĵµÓпÉÄÜ¡°Ö»ÓÐĿ¼»òÕßÄÚÈݲ»È«¡±µÈÇé¿ö£¬ÇëÏÂÔØÖ®Ç°×¢Òâ±æ±ð£¬Èç¹ûÄúÒѸ¶·ÑÇÒÎÞ·¨ÏÂÔØ»òÄÚÈÝÓÐÎÊÌ⣬ÇëÁªÏµÎÒÃÇЭÖúÄã´¦Àí¡£
΢ÐÅ£ºfanwen365 QQ£º370150219
Copyright © ÔÆÌ⺣ All Rights Reserved. ËÕICP±¸16052595ºÅ-3 ÍøÕ¾µØÍ¼ ¿Í·þQQ£º370150219 ÓÊÏ䣺370150219@qq.com