creating object by passing a character to function???

i am asked to write a function that accepts a character as argument and creates the object on the name of recieved character

//class name : CString

CString(char a)
{
CString a;
}

//main portion
CString('a');
the constructor CString will b executed and an object of class CString will be created???where i am wrong..plz help me
Last edited on
i think what they mean is that you are to create a class called CString which takes as a parameter a const char* and assigns the name of the class to the passed value:
1
2
3
4
5
6
7
8
9
class CString{
public:

CString(const char* Name):
myName(Name)
{};

const char* Name;
};
In C/C++ all names are declared statically during compilation of the program. So you can not dynamically introduce a new name in the program.
Last edited on
Topic archived. No new replies allowed.