Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- template<typename trik>
- trik Dodaj(trik liczba,trik liczba1){
- return liczba+liczba1;
- }
- template<typename T>
- class Punkt{
- T x;
- T y;
- public:
- Punkt(T xx,T yy){
- this->x=xx;
- this->y=yy;
- }
- void Drukuj();
- };
- template<typename M>
- void Punkt<M>::Drukuj(){
- cout<<"x="<<x<<" y="<<y<<endl;
- }
- int main(){
- int x=5,y=4,wynik;
- double a=1.7,b=1.4,wynik1;
- wynik=Dodaj(x,y);
- wynik1=Dodaj(a,b);
- cout<<wynik<<endl;
- cout<<wynik1<<endl;
- Punkt<int> trik(3,4);
- trik.Drukuj();
- Punkt<double> triczek(3.8,7.1);
- triczek.Drukuj();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement