Reputation: 1838
Is it possible to create String class with String.cpp and String.h in c++ stl project?
String.h
#include <string>
class String {
public:
static std::string Replace(const std::string& str, const std::string& oldValue, const std::string& newValue);
};
There are compilation errors unless the class is renamed to something else like Stringy
Upvotes: 0
Views: 161
Reputation:
Instead of a class with only static members, you use a namespace in C++.
#include <string>
namespace String {
std::string Replace(const std::string& str, const std::string& oldValue, const std::string& newValue);
};
Upvotes: 4
Reputation: 688
You need to remove the static from the class declaration and your posted code works just fine then.
Upvotes: 3