|
-
February 24th, 2009, 11:49 AM
#10
Re: Storing Objects in an Array
 Originally Posted by skycrazy123
I declared them private in the header, and it seemed to work.
Yes, that is a correct fix since you want info to a non-static member variable so that each MyClass has its own copy.
By the way, you should #include <string>, not <string.h> since you are using std::string instead of the string functions inherited from C (in which case you should #include <cstring>). Also, you should remove the using directive at file scope (using namespace std; ) from the header file. To be const-correct, your get_info() member function should be declared const.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|