Class interdependency circle

This is a discussion on Class interdependency circle within the C++ Programming forums, part of the General Programming Boards category; I've got two classes: matrix, and ffbyte. They both work fine, and ffbyte is loaded as a header in matrix, ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    12

    Class interdependency circle

    I've got two classes: matrix, and ffbyte. They both work fine, and ffbyte is loaded as a header in matrix, which is a header in main.

    The elements in the matrices are ffbytes. This works fine, except... I want to make a function in ffbyte that has a return type (and uses inside) a matrix. Because ffbyte is declared before matrix, it won't let me do that. And I can't put it the other way round, because the matrix elements must be ffbytes.

    Is there any way of resolving this?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Does it have to be a member function? Can it be a plain old function (possibly a friend) that takes a matrix argument (or whatever) and returns a ffbyte?

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    12
    I actually figured this out just now...

    putting

    class <classname>;

    at the top of the file, works like the prototype functions in the classes. Fixes my interdependency issues.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 08:10 AM
  2. Specializing class
    By Elysia in forum C++ Programming
    Replies: 6
    Last Post: 09-28-2008, 04:30 AM
  3. Defining derivated class problem
    By mikahell in forum C++ Programming
    Replies: 9
    Last Post: 08-22-2007, 02:46 PM
  4. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM

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