Hi guys. I've worked on OOP before, and since in general 'get' functions are used to return private attributes in classes, I was thinking how I could make this test code work.
#ifndef _testing_h
#define _testing_h
class Testing
{
private:
char * name;
public:
Testing();
Testing(char*);
~Testing();
char* getName();
void setName(char name[]);
}
#endif;
Here's the get function code. It doesn't seem to work. Removing the const
helps though, but that would defeat the purpose of having a private attribute.
char* Testing::getName() const
{
return name;
}
Also, can I directly assign a character array to a pointer?
Something like name = newName
when name is a char* type.