ext/dl/sample/c++sample.C


DEFINITIONS

This source file includes following functions.
  1. Person
  2. Person
  3. get_name
  4. get_age
  5. set_age


   1  #include <stdio.h>
   2  
   3  class Person {
   4  private:
   5    const char *name;
   6    int age;
   7  
   8  public:
   9    Person(const char *name, int age);
  10    const char * get_name();
  11    int get_age();
  12    void set_age(int i);
  13  };
  14  
  15  Person::Person(const char *name, int age)
  16    : name(name), age(age)
  17  {
  18    /* empty */
  19  }
  20  
  21  const char *
  22  Person::get_name()
  23  {
  24    return name;
  25  }
  26  
  27  int
  28  Person::get_age(){
  29    return age;
  30  }
  31  
  32  void
  33  Person::set_age(int i){
  34    age = i;
  35  }