본문 바로가기
코딩/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;


}

'코딩 > C++' 카테고리의 다른 글

ellipsis  (0) 2024.05.28
argc, argv  (0) 2024.05.28
Constructor  (0) 2024.05.28
Encapsulation  (0) 2024.05.28
vector를 스택처럼 사용  (0) 2024.03.21