C++
- voluntas
- @ignis_fatuus
- ブン
- @Linda_pp
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- I (@wx257osn2)
- Tommy6
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
32
1
2
3
4
5
class item
6
{
7
public:
8
item(std::string startItemName, int startItemCount){
9
itemName = startItemName;
10
itemCount = startItemCount;
11
}
12
13
inline int getItemCount(){return itemCount;}
14
inline std::string getItemName(){return itemName;}
15
16
inline void setItemCount(int newItemCount){itemCount = newItemCount;}
17
inline void setItemName(std::string newItemName){itemName = newItemName;}
18
19
private:
20
std::string itemName;
21
int itemCount;
22
};
23
24
int main(void) {
25
item it("hoge", 123);
26
std::cout << it.getItemCount() << ' ' << it.getItemName() << '\n';
27
it.setItemCount(334);
28
it.setItemName("fuga");
29
std::cout << it.getItemCount() << ' ' << it.getItemName() << '\n';
30
return 0;
31
}
32
$ g++ prog.cc -Wall -Wextra -std=c++98
Start
prog.cc:1:9: warning: #pragma once in main file 1 | #pragma once | ^~~~
123 hoge 334 fuga
0
Finish