Answers for "c++ class member initialization"

C++
1

c++ class member initialization

class Test  {
private:
  std::string data;
public:
  test(std::string data) : data(data) {}
  std::string getData() {
    return data;
  }
};

int main() {
  Test test("This is just some random Text");
  std::cout << test.getData() << std::endl;
  return 0;
}
Posted by: Guest on June-10-2020

Code answers related to "c++ class member initialization"

Browse Popular Code Answers by Language