-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnamspa07.cpp
More file actions
27 lines (26 loc) · 785 Bytes
/
namspa07.cpp
File metadata and controls
27 lines (26 loc) · 785 Bytes
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
//namspa07.cpp
#include <iostream>
using namespace std;
int ano1 = 2001; //vaeiável global
namespace teste //criação do namespace teste
{
int ano2 = 2002;
int ano1 = 2003;
void exibe();
}
int main()
{
cout << "Função main()" << endl;
cout << "variável global ano1: " << ano1 << endl;
cout << "variável ano1 do namespace teste: " << teste::ano1 << endl;
cout << "variável ano2 do namespace teste: " << teste::ano2 << endl << endl;
teste::exibe(); //Chama a função exibe()
return 0;
}
void teste::exibe() //Definição da função exibe()
{
cout << "Função exibe()" << endl;
cout << "variável global ano1: " << ::ano1 << endl;
cout << "variável ano1 do namespace teste: " << ano1 << endl;
cout << "variável ano2 do namespace teste: " << ano2 << endl;
}