Gadget
hasname.h
Go to the documentation of this file.
1 #ifndef hasname_h
2 #define hasname_h
3 
4 #include "gadget.h"
5 
10 class HasName {
11 public:
15  HasName() { name = new char[1]; name[0] = '\0'; };
20  virtual ~HasName() { delete[] name; };
25  HasName(const char* givenname) {
26  name = new char[strlen(givenname) + 1];
27  strcpy(name, givenname);
28  };
33  const char* getName() const { return name; };
34 private:
38  char* name;
39 };
40 
41 #endif
This is the base class for any object that has a name.
Definition: hasname.h:10
const char * getName() const
This will return a null terminated text string containing the name of the object.
Definition: hasname.h:33
virtual ~HasName()
This is the default HasName destructor.
Definition: hasname.h:20
HasName()
This is the default HasName constructor.
Definition: hasname.h:15
HasName(const char *givenname)
This is the HasName constructor for a specified name.
Definition: hasname.h:25