cpp how to initialize a class code example
Example: 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;
}