코딩/C++
class
by sonysame
2024. 5. 28.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Friend {
public:
string m_name="abc";
string address="def";
int age=1;
double height=2;
double weight=3;
void print() {
cout << m_name << " " << address << " " << age << " " << height << " " << weight << endl;
}
};
int main() {
Friend jj{ "Jack Jack","Uptown",2, 30, 10 };
jj.print();
vector<Friend> my_friends;
my_friends.resize(2);
for (auto& ele : my_friends)ele.print();
return 0;
}