#include <iostream>
#include <string>
using namespace std;
namespace worker {
char name[20] = { '0' };
int overtime = 0;
void Show(char name[], int overtime)
{
cout << "name: \t" << name << "\novertime: \t" << overtime << endl;
}
}
namespace student {
char name[20] = { '0' };
float score = 0;
void Show(char name[], int score)
{
cout << "name: \t" << name << "\nscore: \t" << score << endl;
}
}
void main()
{
using namespace student;
strcpy_s(name, 20, "abc");
score = 99.9;
Show(name, score);
cout << endl << endl;
strcpy_s(worker::name, 20, "efg");
worker::overtime = 90;
worker::Show(worker::name, worker::overtime);
}
'Program language > C++' 카테고리의 다른 글
[vscode] cygwin으로 설치한 gdb로 c++ 디버깅 안될 때 해결방법 (0) | 2023.07.24 |
---|---|
[C++] 구조체와 포인터 (0) | 2021.04.22 |