illegal copy constructor required?

This is a discussion on illegal copy constructor required? within the C++ Programming forums, part of the General Programming Boards category; I'm working on a recursive function that has a class as an argument: Code: board_t solve(board_t board, int x, int ...

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

    illegal copy constructor required?

    I'm working on a recursive function that has a class as an argument:
    Code:
    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);
          else
            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
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,805
    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.
    Woop?

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 Cprogramming.com
    Replies: 15
    Last Post: 03-06-2005, 02:53 PM
  4. Copy Constructor Help
    By Jubba in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2001, 10:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21