1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <iostream>
using namespace std;
class Printer {
private:
string str;
public:
void setstring(string g_str) {
str = g_str;
}
void ShowString() {
cout << str << endl;
}
};
int main() {
Printer pnt;
pnt.setstring("hello world!");
pnt.ShowString();
pnt.setstring("I love c++");
pnt.ShowString();
return 0;
}
|
![](https://blog.kakaocdn.net/dn/dqGBjC/btqCpQOZgQC/iirx9nxxzhE0hxrhfdkQG1/img.png)
'C++' 카테고리의 다른 글
열혈강의 c++ 문제 3-2 클래스의 정의 (0) | 2020.03.04 |
---|---|
C++ 기초 - Call-by-reference 구현 (열혈 c++ 프로그래밍 02-1 문제) (0) | 2020.01.01 |
for문을 사용하여 알파벳 A부터 Z까지 출력 (0) | 2019.01.04 |
C++ 프로그래밍 기초 - 1부터 100사이의 짝수의 합을 구하는 프로그램 (0) | 2019.01.04 |
C++ 프로그래밍 기초 - if else 정수를 두개 입력받아 최대값을 구하는 프로그램을 작성하라. (0) | 2019.01.04 |