ADT Initialization/Passing of Array from Friended ADT

This is a discussion on ADT Initialization/Passing of Array from Friended ADT within the C++ Programming forums, part of the General Programming Boards category; Sorry if the title is unclear, it's hard to put into a sentence what my question is. I have two ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    13

    Question ADT Initialization/Passing of Array from Friended ADT

    Sorry if the title is unclear, it's hard to put into a sentence what my question is. I have two ADT classes, one is grid the other is blob. Grid contains only the private variables:

    Code:
    char Blob_Data[HEIGHT - 1][WIDTH - 1]; 
    int Visited_Blobs[HEIGHT - 1][WIDTH - 1];
    The blob class is friended to Grid so it should be able to use both these arrays as it's own private variables (i think). But when I try to execute Blob functions, they say that the two arrays are undefined. When using the arrays in the blob functions, I'm not passing them at all since they're priv variables. Just typing them in the blob functions as say:

    Code:
    cout << Blob_Data[row_loc][col_loc];
    Blob has both a default constructor:

    Code:
    Blob::Blob(){
        row_loc = 0;
        col_loc = 0;
    }
    and another constructor:

    Code:
    Blob::Blob(int column, int row){
        row_loc = row;
        col_loc = column;
    }
    In Blob's private variables I have:

    Code:
    private:
        int row_loc, col_loc;
        Grid G;
    Now i'm pretty sure I'm supposed to declare a Grid object there so the arrays exist, but not sure if there or in the blob constructors is the place to do it. I was going to declare the arrays in the blob constructors also, but couldn't figure out if that was the right place, or how to code it. If i'm not clear here I can post all the code or clarify any of the code. Thanks in advance for any help.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    13
    *Bump*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 11:33 AM
  2. Replies: 7
    Last Post: 11-25-2008, 01:50 AM
  3. An ADT as an array.
    By Rad_Turnip in forum C Programming
    Replies: 1
    Last Post: 09-19-2006, 02:25 PM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 05:15 AM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM

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