lundi 4 juin 2018

How to initialize field from type "const char*" in this case?

given class with field const char* filename; so that the name of the class is for example MyClass.

#include <cstring>
class MyClass{
const char* filename;
public:
       MyClass(const char* name);
};

How can I initialize the field filename by name?
NOTE: I must do it with strcpy function.
Is there a way to do this with a initialization list?

Aucun commentaire:

Enregistrer un commentaire