C ?????? - PowerPoint PPT Presentation

1 / 62
About This Presentation
Title:

C ??????

Description:

Title: C++ Author: lrf Last modified by: Created Date: 1/13/2005 1:32:34 PM Document presentation format: – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 63
Provided by: lrf9
Category:

less

Transcript and Presenter's Notes

Title: C ??????


1
C??????
  • ?4? ????

2
  • ????C????????????
  • ?????????????????????????
  • ????????????,?C????????

3
?4? ????
  • 4.1 ???????
  • 4.2 ?????
  • 4.3 ????
  • 4.4 ????
  • 4.5 ??????
  • 4.6 ??????
  • 4.7 ?????????
  • 4.4 ????
  • 4.9 ?????????

4
  • 4.1 ?????????????

5
4.1 ?????????????
  • 1???
  • ????????(??)????,?????????????????????
  • ???????????,???????????
  • ????????????????(??????????)?
  • ?????????????????????????
  • ????????????

6
4.1 ?????????????
  • 2???
  • ?????????????????,??????????
  • ?????????????,??????????????,??????????,????????,?
    ???????
  • ?????????

7
4.1 ?????????????
  • 3???
  • ?C????????????,?????????????????,?????????

8
4.1 ?????????????
  • 4????
  • ??????,??????????
  • ??????????,????????????
  • ?????????????????????????

9
  • 4.2 ????

10
4.2.1 ????
  • ?????????????(OOP)?????????
  • ??????????????????
  • ???????????????????????

11
4.2.1 ????
  • C?????????????????????????????(??????)???????(??
    ??)????????????????????
  • C?,?????????????????????????????????????????,???
    ?????????????????

12
4.2.1 ????
  • ???????????,????
  • class ???
  • public
  • ????(????)
  • private
  • ????
  • protected
  • ?????

13
4.2.2 ????
  • class????????,?????????,???C??????,?????????
  • ???????????(?????????),???????,???private?public?p
    roctected?????????????????????????,?????????,?????
    ????????

14
4.2.2 ????????
  • ??????????????????????????
  • ???????
  • ????(Public)
  • ????(Private)
  • ????(Protected)

15
4.2.2 ????????
  • 1???????
  • ????public????,??????????,????????????????????????
    ????????private?????

16
4.2.2 ????????
  • 2???????
  • ????private????,???????????,???????????????
  • ?????????????????,????private?????

17
4.2.2 ????????
  • 3?????
  • ??protected????????????????????????,????????????
    (???)????protected????
  • ??
  • ?????,???????????,?????private??,????????????

18
4.1 ???????
  • ??

class Student //???? private int
id char20 name int age float
score public void getscore() void
printstu()
19
4.2.3 ??????
  • ????????????????????????????????,?????????????????
    ?????????????????????
  • ?????????????????
  • ????? ???????(???)
  • ???

20
4.2.3 ??????
  • ????????????????
  • (1)?????????????????,??????????????inline?????????
    ???
  • ????Record?????regist?show??????????????
  • class Record
  • private
  • char bookname20
  • int number

21
4.2.3 ??????
  • public
  • void regist(char a,int b)
    //????regist()???
  • strcpy(bookname,a) //?????bookname??
  • numberb //?????number??
  • void show() //????show()???
  • coutltlt??ltltbooknameltltendl
  • coutltlt??ltltnumberltltendl

22
4.2.3 ??????
  • (2)???????????,????????????????,???????????????
  • ???????????????????????????(????????????
    ????????????)?
  • ????????????
  • ????? ???????(????)
  • ??

23
4.2.3 ??
  • 1??????
  • ???????,??????????
  • ?? ????? ?? ???
  • ?????????Record,?
  • Record book1,book2 //book1,book2?Record????
    ??
  • ???????,???????,?????????,????????(????)???
    ??,??????????,??????????????????(??????),?????????
    ???????????????????????????????

24
4.2.3 ??
  • 2? ???????
  • ???????????????????????????,??????
  • ???.?????
  • void main()
  • Record book1,book2 //????book1?book2
  • //??????regist,?book1???????
  • //bookname?number??
  • book1.regist(C????, 1001)
  • //??????regist,?book2?????????
  • book2.regist(C????, 1002)

25
4.2.3 ??
  • //??????show,??book1???????
  • //bookname?number??
  • book1.show()
  • //??????show,??book2???????
  • //bookname?number??
  • book2.show()

26
  • 4.3 ?????????

27
4.3.1 ????
  • ????????????????????,????????????????,????????
  • ???????????????????,???????????????,?????????
  • C????????????????????????,???????
  • ??????????????????,?????????????????,?????????

28
4.3.1 ????
  • ????????????
  • class ??
  • public
  • ??(???) //???????
  • //??????
  • ????(???) //???????
  • //???

29
4.3.1 ????
  • ???????
  • ?????????????,??????
  • ????????????
  • ????????,???????????????????
  • ??????????????????????????,??????

30
4.3.1 ????
  • ?????????????????,??????????????????????????
  • ???????????????????????
  • ?????????????????,???????????????????????

31
4.3.2 ??????
  • ????????????????,???????????????????????????????
    ???????
  • class ??
  • public
  • ??(??)//????
  • ??(?? ???)//??????
  • ...
  • ???(?? ???)//?????????
  • ???

32
4.3.2 ??????
  • ????????????
  • ?????????????????????,???????????????????
  • int main()
  • Point A(1,2)
  • Point B(A) //?????????
  • coutltltB.GetX()ltltendl

33
4.3.2 ??????
  • ??????????,?????,???????,???????????????
  • void fun1(Point p)
  • coutltltp.GetX()ltltendl
  • int main()
  • Point A(1,2)
  • fun1(A) //????????

34
4.3.2 ??????
  • ????????????,???????????????
  • Point fun2()
  • Point A(1,2)
  • return A //????????
  • int main()
  • Point B
  • Bfun2()

35
???????
  • ?????????????????????????
  • ??????????????,???????new?????????????????????????
    ????????,??????,??????????????????????????????
  • ????,????????????????,????????????????????????

36
4.3.3 ????
  • ?????????,?????????????????????,????????,?????????
    ?????????
  • ???????????????,??????????????
    ,??????,????,??????,?????,????????????,???????
  • ??????????
  • ??()
  • ???
  • ?(1)???????????????

37
4.3.3 ????
  • (2)??????????,??????????,??????????????????
  • (3)??????????,??????????????????????,?????????????
    ??(??new???????)?,???????????????,???????
  • (4)???????????????????????????????????

38
4.3.3 ????
  • ??Teacher??????name??????,????????????
  • include ltwindows.hgt
  • include ltiostream.hgt
  • //???
  • class Teacher
  • private
  • char name
  • int age
  • public

39
4.3.3 ????
  • Teacher(char i, int a ) //??????Teacher
  • namenew charstrlen(i)1 //?new?name???????
  • strcpy (name, i)
  • age a
  • cout ltlt "\n??????Teacher "ltlt endl
  • Teacher ( ) //??????Teacher
  • delete name
  • coutltlt??????Teacher"ltlt endlltltendl
  • void show()

40
4.3.3 ????
  • void Teacher show ()
  • cout ltlt " ??"ltltnameltlt" "ltlt"??"ltltageltlt endl
  • void main() //???
  • Teacher obj ("???", 25)
  • obj.show()
  • ????????
  • ??????Teacher
  • ????? ?? 25
  • ??????Teacher

41
  • 4.4 ????

42
4.4.1 ??
  • ????(??????),?????????????????????????,???????????
    ?????????
  • ??????????,??????????????,??????????????????

43
4.4.1 ??
  • ??????????,????????????????,??????????????????????
    ????,???????????????
  • ????????????,??????????????,?????????????????

44
4.4.1 ??
  • ???????????????
  • ????(???)????1(???), ????2(???),
  • //?????
  • ??,????1(???), ????2(???),??????,??????????????

45
4.4.1 ??
  • ??????????????
  • ????????????(?????????,???????)????????????
    ?(???????????)
  • (??????????????????)
  • ?????????(?????),???????????????????????

46
4.4.1 ??????
  • ??????,???
  • ?????????????,????,???????????
  • ?????????????????,???????????

47
4.4.1 ??????????
  • ??????????????????,???????????????,???????????,???
    ????????????,?????????,???????????????????????????
  • class Fred //??????
  • class Barney
  • Fred x //???Fred???????
  • class Fred
  • Barney y

48
4.4.1 ??????????
  • class Fred //??????
  • class Barney
  • public
  • void method()
  • x-gtyabbaDabbaDo() //??Fred????????????
  • private
  • Fred x//??,????????,????Fred??????
  • class Fred
  • public
  • void yabbaDabbaDo()
  • private
  • Barney y

49
4.4.1 ??????????
  • ???????????????,???????????,????????????

50
4.5 UML??
51
4.5 UML??
  • UML???????????????????
  • UML????????
  • ??(Things)UML????????,????????????,?????????????
  • ??(Relationships)????????????
  • ?(Diagrams)??????????????

52
UML??4??????
  • ????(Structural things)
  • ????(Behavioral things)
  • ????(Grouping things)
  • ????(Annotational things)

53
UML????
  • ??(Dependencies)
  • ??(Association)
  • ??(Generalization)
  • ??(Realization)

54
UML??9??
  • ??(Class diagram)
  • ???(Object diagram)
  • ???(Use case diagram)
  • ???(Sequence diagram)
  • ???(Collaboration diagram)
  • ???(Statechart diagram)
  • ???(Activity diagram)
  • ???(Component diagram)
  • ???(Deployment diagram)

55
??
UML????
  • ??Clock??????
  • Clock??????

56
???
UML????
57
???????????
UML????
  • ????
  • ????A??,?B???,???A????B,???A???B

58
???????????
UML????
  • ??????
  • ?????A????B???????A??????????,????B????A??????
    ?B???????????

59
???????????
UML????
  • ?????????

???????????????????,??????????????????
60
???????????
UML????
  • ??????

61
??
UML????
  • ?UML???,????????????,????????UML??????,???????????
    ????????

62
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com