View Problem
Define a class
Declare a class named Greeter that takes a string on creation and greets using this string if you call the
Submit a new solution for ruby, cpp, fsharp, or clojure
There are 14 other solutions in additional languages (csharp, erlang, fantom, go ...)
"greet" method.
cpp
class Greeter
{
public:
Greeter(const std::string& whom);
void greet() const;
private:
std::string whom;
};
int main()
{
Greeter* gp = new Greeter("world");
gp->greet();
delete gp;
}
Greeter::Greeter(const std::string& whom) : whom(whom) {}
void Greeter::greet() const
{
std::cout << "Hello, " << whom << std::endl;
}
{
public:
Greeter(const std::string& whom);
void greet() const;
private:
std::string whom;
};
int main()
{
Greeter* gp = new Greeter("world");
gp->greet();
delete gp;
}
Greeter::Greeter(const std::string& whom) : whom(whom) {}
void Greeter::greet() const
{
std::cout << "Hello, " << whom << std::endl;
}
Submit a new solution for ruby, cpp, fsharp, or clojure
There are 14 other solutions in additional languages (csharp, erlang, fantom, go ...)




