struct
struct is a class with public default access. Great for plain data.
Example
#include <iostream>
#include <string>
struct P { std::string name; int age; };
int main() {
P p{"Ada", 30};
std::cout << p.name << " " << p.age << "\n";
return 0;
}Result
Ada 30
Exercise
Default access of struct.
struct is by default
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.