With this following code:

Code:
void Display::alloca(){
  p = new bool*[N];
  for (int r=0; r<N; r++)
    p[r] = new bool[N];
}

void Display::dealloca(){
  for (int r=0; r<N; r++)
    delete [] p[r];
  delete [] p;
}

Display::Display(int N1){
  if ( N1<=0 || (N1%2)==0 )
    N = 5;
  else 
    N = N1;
  alloca();
  for (int r=0; r<N; r++){
    for (int c=0; c<N; c++)
      p[r][c] = false;
  }
}

Display & Display::operator =(const Display &d){
  if ( this != &d ){
    if ( N != d.N){
      dealloca();
      N = d.N;
      alloca();      
    }
    for (int r=0; r<N; r++)
      for (int c=0; c<N; c++)
        p[r][c] = d.p[r][c];
  }
  return *this;
}

partial main:

Code:
Display d2(5);
Display d4(3);
d4=d2;

Can I define operator = in tis way? Where return value is void.
I update class object and I give no return value. Perhaps standard operator = will give return class object and I can't change it?
What do you think?

Code:
void Display::operator =(const Display &d){
  if ( this != &d ){
    if ( N != d.N){
      dealloca();
      N = d.N;
      alloca();      
    }
    for (int r=0; r<N; r++)
      for (int c=0; c<N; c++)
        p[r][c] = d.p[r][c];
  }

}