문제 번호 1612. -- 객체기반SW 설계 중간고사 1번

1612: 객체기반SW 설계 중간고사 1번

시간 제한: 1 Sec  메모리 제한: 128 MB
제출: 213  해결 문제 수: 120
[제출][채점 상황 열람][게시판]

문제 설명

#include <iostream>
#include <string>

using namespace std;

class Klass {
public:
	int size;
	string* strs;
public:
	Klass(int s) : size(s) {
		strs = new string[this->size]{ "hello", "world", "c++" };
	}
	~Klass() {
		delete[] strs;
	}
	/* 
	*   main함수가 정상 동작할 수 있도록 copy constructor를 구현하시오.
		--------------------------------
	*/

};

//----------------- 이하 수정 금지 -------------------------------

int main() {
	int i;
	cin >> i;

	Klass k(3);
	{
		Klass p = k;
		cout << p.strs[i] << endl;
	}
	cout << k.strs[i] << endl;

	return 0;
}

입력

출력

도움말

출처

[제출][채점 상황 열람]