1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <iostream>
20 #include <vector>
21
22 namespace vect{
23
24
25 ¦
26 ¦
27 ¦
28 ¦
29 ¦
30
31 template < class T >
32 class Lvalue
33 {
34 public:
35
36
37 Lvalue (){};
38 Lvalue (std::vector<T> in): _ofthings{in}{};
39 Lvalue ( const Lvalue &other );
40 ~Lvalue (){};
41
42
43 std::vector<T>& ofthings(){
44 return _ofthings;
45 };
46
47 void ofthings(std::vector<T> const vec){
48 _ofthings = vec;
49 };
50
51
52
53
54 const Lvalue& operator = ( const Lvalue &other );
55 const T& operator [] (int index)
56 {
57 return (ofthings()[index]);
58 };
59 friend std::ostream &operator << (std::ostream &os, const Lvalue in)
60 {
61 for(int i = 0; i < in._ofthings.size(); i++ ){
62 std::cout << i << "\t";
63 }
64 return os;
65 };
66
67
68 protected:
69 std::vector<T> _ofthings;
70
71 private:
72
73 };
74
75 };
76
77
78 int main ( int argc, char *argv[] )
79 {
80
81 std::cout << "TEST INPUT TO VECTOR" << std::endl;
82 std::vector<int> test {100};
83 for(int i = 0; i<10; i++ ){
84 test[i] = i;
85 std::cout << test[i] << "\t";
86 }
87 std::cout << std::endl;
88 std::cout << "TEST INPUT TO OBJECT" << std::endl;
89 vect::Lvalue<int> test2 {test};
90 for(int j=0, i = 10; j<10; i--, j++){
91 test[j] = i;
92 std::cout << test[j] << "\t";
93 }
94 std::cout << std::endl;
95 std::cout << "__DONE__";
96
97
98
99 return EXIT_SUCCESS;
100 }