struct Person {
std::string name;
int age;
};
Person p = {"Alice", 25};
struct Person {
std::string name = "Alice";
int age = 25;
};
Person p;
struct Person {
std::string name;
int age;
Person(const std::string& n, int a) : name(n), age(a) {}
};
Person p("Alice", 25);
struct Person {
std::string name;
int age;
void init(const std::string& n, int a) {
name = n;
age = a;
}
};
Person p;
p.init("Alice", 25);
struct Person {
std::string name;
int age;
};
Person p = {"Alice", 25};