Thread: Class arrays

  1. #1
    Registered User
    Join Date
    Dec 2008

    Class arrays

    I have two classes. The .h files go something like this:

    class ClassA {
    ClassA::ClassA(int x, char array1[], char array2[]);  <-- constructor which sets some private variables
    class ClassB {
    ClassA classArr[];
    ClassB::readFile(string path);
    inside readFile(string path) function this line causes the program to die and the IDE gives me no error, just crashes. I want to know what's wrong with this assignment.
    classArr[i] = ClassA(anInt, aCharArr, aCharArr2);
    EDIT: Okay, so I guess the issue was that since I only defined the array in header file, I never gave it a size.
    Last edited by Furious5k; 01-16-2011 at 04:38 PM.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Ooh, we get to guess what's in all the dots! This is exciting.

    Probably i has gone out of bounds.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. class composition constructor question...
    By andrea72 in forum C++ Programming
    Replies: 3
    Last Post: 04-03-2008, 05:11 PM
  2. Replies: 7
    Last Post: 05-26-2005, 10:48 AM
  3. Replies: 1
    Last Post: 04-20-2003, 05:02 PM
  4. arrays as class names
    By Katle in forum C++ Programming
    Replies: 2
    Last Post: 11-25-2002, 03:58 PM
  5. Do you store store one off data arrays in a class?
    By blood.angel in forum C++ Programming
    Replies: 5
    Last Post: 06-24-2002, 12:05 PM