mardi 28 juillet 2015

Simple bit of code. It's obviously incomplete as of this point, but it should compile. I'm converting this to Linux from Visual Studio. When I compile with g++ test.cpp I get this error:

In file included from test.cpp:2:0:
String.h: In constructor String::String(char*):
String.h:24:2: error: strcpy is not a member of std std::strcpy(pointer_Object, s);

#ifndef _STRING_H
#define _STRING_H

#include <cstring>
#include "ArrayClass.h"
#include "Exception.h"

class String : virtual public ArrayClass<char>
{

public:
    String();
    String(char* s);

};

String::String() : ArrayClass<char>(1,'\0') {}

String::String(char* s) : ArrayClass<char>(std::strlen(s)+1)
{
    std::strcpy(pointer_Object, s);
}

#endif

It seems like I've been over it backwards and forwards. Any Ideas?

Compiling with these:

  • libgcc-4.9.2-6.fc21.i686

  • gcc-4.9.2-6.fc21.x86_64

  • gcc-c++-4.9.2-6.fc21.x86_64

  • libgcc-4.9.2-6.fc21.x86_64

Aucun commentaire:

Enregistrer un commentaire