Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- template <typename T, std::size_t X>
- class Wektor{
- T z[X];
- public:
- Wektor(){
- for(int i = 0; i < X; i++){
- z[i] = 0; }
- }
- typedef T value_type;
- T& operator[](std::size_t y) {
- return z[y];
- }
- };
- template <typename w, typename q>
- typename w::value_type operator*(w x, q y){
- typename w::value_type sum =0;
- for (int i = 0; i < 3 ;i++){
- sum = sum + x[i]*y[i];
- }
- return sum;
- }
- int main() {
- Wektor<int, 3> wek;
- for ( int i = 0; i < 3; i++){
- std::cout << wek[i] << "\n";
- }
- Wektor<int,3> wek2;
- std::cout <<"\n" << wek*wek2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement