I am a new to c++, I have to set the variable name to an empty string in the class constructor. This is the way i approached it, is this correct?
class test
{
private:
char* name;
prublic:
Test()
{
name[0] = '\0';
}
};
I am a new to c++, I have to set the variable name to an empty string in the class constructor. This is the way i approached it, is this correct?
class test
{
private:
char* name;
prublic:
Test()
{
name[0] = '\0';
}
};
Originally posted by wireless
I am a new to c++, I have to set the variable name to an empty string in the class constructor. This is the way i approached it, is this correct?
class test
{
private:
char* name;
prublic:
Test()
{
name[0] = '\0';
}
};
First off, Test() should be test().
test()
{
name = new char[input desired size];
}
Is what i'd use.