PatrickIRL
Programmer
- Jun 25, 2003
- 383
Hi all,
Been messing around with this code for a bit of fun. Just curious if I'm using the class and pointers as they should be used. I've done something similar in java (sorry).
(FYI - definitely NOT homework or anything like that, just curious, that's all)
Any feedback appreciated,
Patrick
Been messing around with this code for a bit of fun. Just curious if I'm using the class and pointers as they should be used. I've done something similar in java (sorry).
(FYI - definitely NOT homework or anything like that, just curious, that's all)
Any feedback appreciated,
Patrick
Code:
#include <iostream.h>
#include <string.h>
class Test{
public:
void setFirstname(char *firstname){
strcpy(_firstname,firstname);
}
char *getFirstname(){
return _firstname;
}
private:
char _firstname[20];
};
void main()
{
Test test;
test.setFirstname("Patrick");
cout << test.getFirstname() << "\n\n";
}