class.cxx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. class foo_c : public bar_c // Foo class derived from bar
  2. {
  3. float foo; /* Real number */
  4. int bar; /* Integer */
  5. public:
  6. foo_c(float f, int b);
  7. ~foo_c();
  8. // 'get_bar()' - Get the value of bar.
  9. int // O - Value of bar
  10. get_bar()
  11. {
  12. return (bar);
  13. }
  14. // 'get_foo()' - Get the value of foo.
  15. float // O - Value of foo
  16. get_foo()
  17. {
  18. return (foo);
  19. }
  20. // 'set_bar()' - Set the value of bar.
  21. void
  22. set_bar(int b) // I - Value of bar
  23. {
  24. bar = b;
  25. }
  26. // 'set_foo()' - Set the value of foo.
  27. void
  28. set_foo(float f) // I - Value of foo
  29. {
  30. foo = f;
  31. }
  32. // 'set_foobar()' - Set foo and optionally bar (should show default args).
  33. void
  34. set_foobar(float f, // I - Value of foo
  35. int b = 0) // I - Value of bar
  36. {
  37. foo = f;
  38. bar = b;
  39. }
  40. protected:
  41. static int global; /* Global integer */
  42. // 'get_global()' - Get the global integer.
  43. int // O - Integer
  44. get_global()
  45. {
  46. return (global);
  47. }
  48. private:
  49. int barfoo; // Another private integer
  50. public:
  51. // 'get_barfoo()' - Get the barfoo value.
  52. int // O - Barfoo value
  53. get_barfoo()
  54. {
  55. return (barfoo);
  56. }
  57. }
  58. // 'foo_c::foo_c()' - Create a foo_c class.
  59. foo_c::foo_c(float f, // I - Value of foo
  60. int b) // I - Value of bar
  61. {
  62. foo = f;
  63. bar = b;
  64. }
  65. // 'foo_c::~foo_c()' - Destroy a foo_c class.
  66. foo_c::~foo_c()
  67. {
  68. }