Listing 1. Class describing Person attributes.
//-------------- begin Person.h
#ifndef __PERSON_H
#define __PERSON_H
#include "TObject.h""
class Person : public TObject { // need to inherit
// from TObject
private:
int age; // age of person
float height; // height of person
public:
Person(int a = 0, float h = 0) : age(a),
height(h) { }
int get_age(void) const { return age; }
float get_height(void) const { return height; }
void set_age(int a) { age = a; }
void set_height(float h) { height = h; }
ClassDef(test,1) // test person
};
#endif
//--------------- end Person.h
Copyright © 1994 - 2019 Linux Journal. All rights reserved.