30.06.2013 Aufrufe

Softwareentwicklung in C++ - ASC

Softwareentwicklung in C++ - ASC

Softwareentwicklung in C++ - ASC

MEHR ANZEIGEN
WENIGER ANZEIGEN

Erfolgreiche ePaper selbst erstellen

Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.

42 }<br />

43<br />

44 /∗ Copy constructor<br />

45 ∗/<br />

46 Event ( const Event & s r c )<br />

47 {<br />

48 event type = s r c . event type ;<br />

49 }<br />

50<br />

51 /∗ Destructor<br />

52 ∗ Just to make sure that a v i r t u a l d e s t r u c t o r e x i s t s<br />

53 ∗/<br />

54 virtual ˜ Event ( ) { }<br />

55<br />

10.2 Das DDD 293<br />

56 /∗ Returns the type of the event<br />

57 ∗ @return The type of the event as given <strong>in</strong> the constructor<br />

58 ∗/<br />

59 <strong>in</strong>t32 getType ( ) const<br />

60 {<br />

61 return ( event type ) ;<br />

62 }<br />

63 } ;<br />

64<br />

65<br />

66 #endif // s i m p l e e v e n t h<br />

10.2.19 WordEvent<br />

Der hier vorgestellte WordEvent stellt e<strong>in</strong>e Spezialisierung des allgeme<strong>in</strong>en<br />

Events von zuvor dar. Er wird dazu verwendet, den erhaltenen User Input<br />

Wort für Wort an die Applikation weiterzureichen:<br />

1 // simple word event . h − a word event c l a s s<br />

2<br />

3 #ifndef simple word event h<br />

4 #def<strong>in</strong>e simple word event h<br />

5<br />

6 #<strong>in</strong>clude < c s t r i n g><br />

7<br />

8 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−<br />

9 /∗ A c l a s s f o r a s p e c i f i c word event . I s used f o r words that<br />

10 ∗ are <strong>in</strong>put by u sers and have to be passed on .<br />

11 ∗/<br />

12<br />

13 class WordEvent : public Event<br />

14 {<br />

15 protected :<br />

16<br />

17 /∗ The word that a r r i v e d as a user <strong>in</strong>put and has to be<br />

18 ∗ passed on . This i s a copy and has to be deleted <strong>in</strong><br />

19 ∗ the d e s t r u c t o r . Also a 0 po<strong>in</strong>ter i s p o s s i b l e .<br />

20 ∗/<br />

21 char ∗ word ;<br />

22<br />

23 public :<br />

24<br />

25 /∗ Standard constructor<br />

26 ∗ c o p i e s the word that i s passed on to i t<br />

27 ∗/<br />

28 explicit WordEvent( const char ∗ word ) :<br />

29 Event (WORDEVENT) ,

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!