#include <iostream> using namespace std; class List { private: int x[3] ; int y; public : void set (int a[3] ) { for ( int j = 0; j< 3; j++) x[j] = a[j] ; } void sety (int a) { y=a; } int operator [] (int k) { if (k <0 || k >= 3) { cout << "out of bound";exit (0);} return x[k]; } int operator + (List t) { int b; for(int i=0;i<3;i++) { b = x[i]+t.y; return b; } } }; //////////////////////////////////////////////////////// int main() { List ob ; List ob1; int a[3] = {10, 11, 12}; ob1.sety(3); ob.set (a); cout << ob[0] << endl; //10 cout << ob[1] << endl; //11 cout << ob[2] << endl; //12 cout << ob[3]; for(int i=0;i<3;i++) { cout<
List
main
main<code>. As Richard has said, please fill in the details.
///...
operator
[]
+
cout << ob[3];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)