How can I write a program with 3 classes?

Reply

Join Date: Oct 2004
Posts: 6
Reputation: nicoletonyf is an unknown quantity at this point 
Solved Threads: 0
nicoletonyf nicoletonyf is offline Offline
Newbie Poster

How can I write a program with 3 classes?

 
0
  #1
Oct 22nd, 2004
Hello there, I have to write a program using three classes. One for the input, a second for the transaction, and a third one for the report. Can I write the three class definition in one header file? Can I write the three classes in one .CPP file?
Can I find an example of a program like this on the Internet?Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 10
Reputation: Ejaz is an unknown quantity at this point 
Solved Threads: 0
Ejaz's Avatar
Ejaz Ejaz is offline Offline
Newbie Poster

Re: How can I write a program with 3 classes?

 
0
  #2
Oct 23rd, 2004
Yes, you can write all the 3 class definations in one header file and implementation in one source file (in fact, you can write everything in one file as well).

  1. // Class delarations
  2. class A
  3. {
  4. A();
  5. ~A();
  6. void MethodOfA();
  7. };
  8.  
  9. class B
  10. {
  11. B();
  12. ~B();
  13. MethodOfB();
  14. };
  15.  
  16. class C
  17. {
  18. C();
  19. ~C();
  20. MethodOfC();
  21. };
  22.  
  23. // Class Implmentations
  24. A::A()
  25. {
  26. // A ctor
  27. }
  28.  
  29. A::~A()
  30. {
  31. // A ~ctor
  32. }
  33.  
  34. void A::MethodOfA()
  35. {
  36. // MethodOfA
  37. }
  38.  
  39. // ******************
  40. B::B()
  41. {
  42. // B ctor
  43. }
  44.  
  45. B::~B()
  46. {
  47. // B ~ctor
  48. }
  49.  
  50. void B::MethodOfB()
  51. {
  52. // MethodOfB
  53. }
  54.  
  55. // ******************
  56. C::C()
  57. {
  58. // C ctor
  59. }
  60.  
  61. C::~C()
  62. {
  63. // C ~ctor
  64. }
  65.  
  66. void C::MethodOfC()
  67. {
  68. // MethodOfC
  69. }
Regards,

Ejaz.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC