Skip to content

Instantly share code, notes, and snippets.

@Joshix-1
Last active July 11, 2024 17:39
Show Gist options
  • Save Joshix-1/1597e5d36e3cfed1e41356f5e063272c to your computer and use it in GitHub Desktop.
Save Joshix-1/1597e5d36e3cfed1e41356f5e063272c to your computer and use it in GitHub Desktop.
#include <string>
#include <iostream>
#include <memory>
class Foo {
public:
Foo(char *chars) {
std::cout << *(data.get()) << std::endl;
data = std::unique_ptr<std::string>(new std::string(chars));
}
std::unique_ptr<std::string> data;
};
int main() {
char str[2] = {42, 0};
Foo foo = {str};
std::cout << "2: " << *(foo.data.get()) << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment