rozisd,
[ Pobierz całość w formacie PDF ]
//<?php//======================================================================#include <iostream>//----------------------------------------------------------------------using namespace std;//======================================================================class Pkt{public:double X;double Y;public:Pkt& operator=(const double aVal);Pkt& operator=(const unsigned int aVal);Pkt& operator+=(const Pkt& aPkt);Pkt operator++(int);bool operator!=(const Pkt&);public:Pkt():X(0),Y(0){}Pkt(const Pkt& aPkt):X(aPkt.X),Y(aPkt.Y){}Pkt(const unsigned int& aVal);};//======================================================================//----------------------------------------------------------------------bool Pkt::operator!=(const Pkt& aPkt){if( aPkt.X != X )return true;if( aPkt.Y != Y )return true;return false;}//----------------------------------------------------------------------Pkt Pkt::operator++(int){Pkt sKopia(*this);++X; ++Y;return sKopia;}//----------------------------------------------------------------------Pkt::Pkt(const unsigned int& aVal){X = Y = (double)(aVal);}//----------------------------------------------------------------------Pkt& Pkt::operator=(const double aVal){X = aVal;Y = aVal;return *this;}//----------------------------------------------------------------------Pkt& Pkt::operator+=(const Pkt& aPkt){X += aPkt.X;Y += aPkt.Y;return *this;}//----------------------------------------------------------------------Pkt& Pkt::operator=(const unsigned int aVal){X = (double)aVal;Y = (double)aVal;return *this;}//----------------------------------------------------------------------//======================================================================class Pkt3:public Pkt{public:double Z;public:Pkt3():Z(0){}Pkt3(double val):Z(val){}Pkt3(const Pkt3& aPkt3);Pkt3& operator=(const Pkt3& aPkt3);Pkt3 operator-();};//----------------------------------------------------------------------Pkt3::Pkt3(const Pkt3& aPkt3){Pkt::X = aPkt3.X;Pkt::Y = aPkt3.Y;Z = aPkt3.Z;}//----------------------------------------------------------------------Pkt3& Pkt3::operator=(const Pkt3& aPkt3){if( this == &aPkt3 )return *this;Pkt::X = aPkt3.X;Pkt::Y = aPkt3.Y;Z = aPkt3.Z;return *this;}//----------------------------------------------------------------------Pkt3 Pkt3::operator-(){Pkt3 sTmp;sTmp.X = -Pkt::X;sTmp.Y = -Pkt::Y;sTmp.Z = -Z;return sTmp;}//----------------------------------------------------------------------//======================================================================template <class T1, class T2, unsigned int TSize>class Tablica1D{T1 m_tab[ TSize ];T2 m_commonVal;unsigned int m_uSize;public:Tablica1D( unsigned int a_uWypelnienie );Tablica1D( const Tablica1D<T1,T2,TSize>& a_Tab );public:Tablica1D<T1,T2,TSize>& operator=( const Tablica1D<T1,T2,TSize>& a_tab);Tablica1D<T1,T2,TSize> operator++( int );Tablica1D<T1,T2,TSize> operator+( const Tablica1D<T1,T2,TSize>& a_tab );bool operator!=( const Tablica1D<T1,T2,TSize>& a_tab );Tablica1D<T1,T2,TSize> operator-();};//======================================================================//----------------------------------------------------------------------template <class T1, class T2, unsigned int TSize>Tablica1D<T1,T2,TSize> Tablica1D<T1,T2,TSize>::operator-(){Tablica1D<T1,T2,TSize> sTmp(0);for( unsigned int i = 0; i < m_uSize; ++i )sTmp.m_tab[i] = -m_tab[i];sTmp.m_commonVal = -m_commonVal;return sTmp;}//----------------------------------------------------------------------template <class T1, class T2, unsigned int TSize>bool Tablica1D<T1,T2,TSize>::operator!=( const Tablica1D<T1,T2,TSize>& a_Tablica ){if( m_uSize != a_Tablica.m_uSize )return true;if( m_commonVal != a_Tablica.m_commonVal )return true;unsigned int sSize = ( m_uSize < a_Tablica.m_uSize )?(m_uSize):(a_Tablica.m_uSize);for( unsigned int i = 0; i < sSize; ++i )if( m_tab[i] != a_Tablica.m_tab[i] )return true;return false;}//----------------------------------------------------------------------template <class T1, class T2, unsigned int TSize>Tablica1D<T1,T2,TSize> Tablica1D<T1,T2,TSize>::operator+( const Tablica1D<T1,T2,TSize>& a_tablica ){unsigned int sSize = ( m_uSize < a_tablica.m_uSize )?(m_uSize):(a_tablica.m_uSize);Tablica1D<T1,T2,TSize> sKopia(*this);sKopia.m_uSize = sSize;for( unsigned int i = 0; i < sSize; ++i )sKopia.m_tab[i] += a_tablica.m_tab[i];sKopia.m_commonVal += a_tablica.m_commonVal;return sKopia;}//----------------------------------------------------------------------template <class T1, class T2, unsigned int TSize>Tablica1D<T1,T2,TSize> Tablica1D<T1,T2,TSize>::operator++( int ){Tablica1D<T1,T2,TSize> sKopia(*this);for( unsigned int i = 0; i < m_uSize; ++i )m_tab[i]++;m_commonVal++;return sKopia;}//----------------------------------------------------------------------template <class T1, class T2, unsigned int TSize>Tablica1D<T1,T2,TSize>& Tablica1D<T1,T2,TSize>::operator=( const Tablica1D<T1,T2,TSize>& a_Tab){if( this->m_uSize != a_Tab.m_uSize ){unsigned int sSize = (m_uSize < a_Tab.m_uSize )?(m_uSize):(a_Tab.m_uSize);for( unsigned int i = 0; i < sSize; ++i )m_tab[i] = a_Tab.m_tab[i];m_uSize = sSize;return *this;}else{m_uSize = (unsigned int)(TSize);for( unsigned int i = 0; i < m_uSize; ++i )m_tab[i] = a_Tab.m_tab[i];}m_commonVal = a_Tab.m_commonVal;return *this;}//----------------------------------------------------------------------template <class T1, class T2, unsigned int TSize>Tablica1D<T1,T2,TSize>::Tablica1D( unsigned int a_uWypelnienie ){m_uSize = (unsigned int)(TSize);for( unsigned int i = 0; i < m_uSize; ++i )m_tab[i] = (T1)(a_uWypelnienie);m_commonVal = (T2)(a_uWypelnienie);}//----------------------------------------------------------------------template <class T1, class T2, unsigned int TSize>Tablica1D<T1,T2,TSize>::Tablica1D( const Tablica1D<T1,T2,TSize>& a_Tab ){if( TSize != a_Tab.m_uSize ){for( unsigned int i = 0; i < TSize; ++i )m_tab[i] = (T1)(0);m_commonVal = (T2)(0);return;}m_uSize = (unsigned int)(TSize);for( unsigned int i = 0; i < m_uSize; ++i )m_tab[i] = a_Tab.m_tab[i];m_commonVal = a_Tab.m_commonVal;}//======================================================================int main(){Tablica1D<float, int, 12> A1(10), B1(A1);Tablica1D<Pkt, double, 5> A2(12), B2(A2);Tablica1D<Pkt3, int, 50> A3(-1), B3(A3);B1 = (A1++) + B1;B2 = (A2++) + B2;B3 = -A3;if( B2 != A2 )std::cout << "B2 != A2 !!! " << endl;return 0;}//======================================================================//?>
[ Pobierz całość w formacie PDF ]
Tematy
- Indeks
- Ruse, Filozofia UW, Filozofia Biologii
- Rules and respect intermediate, anusiek27
- Roof Design - Daab Press, mj
- RuneAge--gra-karciana - instrukcja PL, gry planszowe +karciane
- Rynek produkcji wibroprasowanych drobnowymiarowych elementów betonowych w Polsce, 1. Projektowanie, c) Konstrukcje, 1) Konstrukcje Żelbetowe i Sprężone, artukuły
- Rocznica e 1526, e
- Ryszard Kapuściński - Zaproszenie do Gruzji, E-books, Kapuściński Ryszard
- Rozporządzenie w sprawie struktury dok. elektronicznych, prawo informatyczne
- Rounders Hazardzisci 1998, Napisy
- Rys historyczny o huculach 1863, Historia Polski - ponad 7400 książek(1)
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- ola.pev.pl