hy! I am writing an integer array class. but there is problem to return array from getter function. any one tell me the procedure of this task.
And tell about extract operator for that class.
#include<iostream>
using namespace std;
class integer{
friend ostream& operator<<(ostream& output, const integer& num);
private:
int array[10];
public:
integer(); //default constructor
integer(int arr[], int n); // overloaded constructor
void setArrayElements(int arr[], int n); // setter function for array elements
integer getArray(); // getter for array elements
integer operator * (const integer &arrb)const;
void display(); // display array elements
};
main()
{
int arrayb[10];
for(int i = 0; i < 10; i++ )
{
cout << "Enter value = ";
cin >> arrayb[i];
}
integer a(arrayb, 10);
a.display();
cout<<endl;
system("pause");
}
integer::integer()
{
for(int i = 0; i < 10; i++ )
array[i] = 0;
}
integer::integer(int arr[], int n)
{
setArrayElements(arr, 10);
}
void integer::display()
{ cout<<endl;
for(int i = 0; i < 10; i++)
cout<<"\t"<<array[i]<<endl;
}
void integer::setArrayElements(int arr[], int n)
{
for(int i = 0; i < 10; i++)
array[i] = arr[i];
}
integer integer::operator * (const integer &arrb)const
{
for(int i = 0; i < 10; i++)
{
integer temp;
}
}
integer integer:: getArray() // getter for array elements
{
// here what to do?
}