<iostream> was included in "error.h"; the reason I did not fill it was because I am not getting what I expected. This is just an exercise. I thought I understood pointers but I obviously do not. If I could figure out why lines 34 and 35 print junk instead of "hello" I would finish this exercise.
Your constructor is re-declaring size and copy to be local variables, which means you are never
actually filling out the "size" and "copy" class/struct data members. [Not to mention that you
don't ever copy the original string to either the data member "copy" or the local variable "copy"]
This is your problem.
Couple of other things:
Add #include <iostream> anyway. It is never a good idea to rely on another header file to include
a header file you need.
Don't use the names strdup or copy in the global namespace, because both of those names are
already used.
Why are you dynamically allocating an int? ie, why is size a pointer instead of an int?
get() should return a const char*.
If you want the user to be able to call get() and use the resulting const char* as a C-style string,
then you have to make sure you \0 terminate it.
The reason I am doing this is to gain an understanding of pointers and the use of heap memory, (this program has no practical use). It is a slightly modified exercise that I found in a book that I am using.
Thank you for the advise and criticism I appreciate both; I am just sorry that I did not read your response sooner--it would have saved me some time.