NamespaceTest.cpp
Dosyayı İndir
#include <iostream>
#include <locale.h>
using namespace std;
namespace space_one{
int my_variable=3;
int my_function(int x,int y){
return x+y;
}
class my_class{
public:
int my_int;
int my_method(int my_parameter){
return my_int-my_parameter;
}
};
}
namespace space_two{
double my_variable=3.5;
double my_function(double x,double y){
return x*y;
}
class my_class{
public:
double my_double;
double my_method(double my_parameter){
return my_double/my_parameter;
}
};
}
using namespace space_one;
int main0206(){
setlocale(LC_ALL,"Turkish");
cout<<"Uzay Bir - De�i�ken : "
<<my_variable<<endl;
cout<<"Uzay �ki - De�i�ken : "
<<space_two::my_variable<<endl;
cout<<"Uzay Bir - ��lev : "
<<my_function(3,4)<<endl;
cout<<"Uzay �ki - ��lev : "
<<space_two::my_function(3,4)<<endl;
my_class object_one;
object_one.my_int=8;
cout<<"Uzay Bir - Tarla : "
<<object_one.my_int<<endl;
cout<<"Uzay Bir - Y�ntem : "
<<object_one.my_method(2)<<endl;
space_two::my_class object_two;
object_two.my_double=8;
cout<<"Uzay �ki - Tarla : "
<<object_two.my_double<<endl;
cout<<"Uzay �ki - Y�ntem : "
<<object_two.my_method(2)<<endl;
return 0;
}
Dosyayı İndir