Thread: illegal copy constructor required?

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002

    illegal copy constructor required?

    I'm working on a recursive function that has a class as an argument:
    board_t solve(board_t board, int x, int *rowtarget, int* coltarget) {
      int i;
      board_t temp = board;
      for (i = 0; i < board.size; ++i) {
        temp.board[x][i] = true;
        if (ok(temp,rowtarget,coltarget)) {
          if (x < board.size - 1)
            return solve(temp,x+1,rowtarget,coltarget);
            return temp;
        temp = board;
      printf("no solutions found!\n");
      return board;
    so I implemented a copy constructor and operator= for the class. Now when I compile my code I get the following error on the line where the recursive function calls itself:
    error: no matching function for call to `board_t::board_t(board_t)'
    board.h:9: note: candidates are: board_t::board_t(board_t&)
    board.h:8: note: board_t::board_t(int)
    I tried just making a duplicate of my copy constructor like that, but it gave me wicked errors. I'm not sure what's causing this, but I've tried everything I can think of and nothing works.
    Illusion and reality become impartiality and confidence.

  2. #2
    Join Date
    Aug 2002
    Tucson, Arizona
    Have you overloaded the = operator in your class cause if not you can't just assign the class to another class which is probably the cause of the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling copy constructor from template
    By Ancient Dragon in forum C++ Programming
    Replies: 3
    Last Post: 09-28-2005, 01:54 PM
  2. dynamic memory alloccation & returning objects
    By haditya in forum C++ Programming
    Replies: 8
    Last Post: 04-21-2005, 11:55 PM
  3. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of
    Replies: 15
    Last Post: 03-06-2005, 03:53 PM
  4. Copy Constructor Help
    By Jubba in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2001, 11:15 AM