I am trying to overload the >> operator to rotate the elements in the array.I have removed the array declaration and initialization for shorten the code. But compiler is giving error as "invalid use of undefined type 'class ABC'." and many more.
#include<iostream>
using namespace std;
class ABC
{
int iarr[10],n2,n3;
char carr[10];
Public:
ABC();
ABC(int arr[],char car[],int n,int n1)
{
n2=n; n3=n1;
for(int i=0;i<n;i++)
iarr[i]=arr[i];
for(int i=0;i<n1;i++)
carr[i]=car[i];
}
ABC operator>>(int n)
{
while(n)
{
int temp;
temp=iarr[n2-1];
for(int i=n2-1;i>=0;i--)
{
iarr[i]=iarr[i-1];
}
iarr[0]=temp;
}
}
void display()
{
for(int i=0;i<n2;i++)
printf("%d\t",iarr[i]);
printf("\n");
for(int i=0;i<n3;i++)
printf("%d\t",carr[i]);
}
};
main()
{
ABC A;
A=ABC(arr,car,n,n1);
A.display();
}
ABC A(arr, carr, n, n1);If you writeABC A; A = ABC(...);you'll need a default ctor and an assignment operator.ninsideoperator>>, so this loopwhile(n)will either not run at all or run infinitely.