I'm trying to help someone with homework.. So you do not have to give me direct answers if you don't want to.. it is not my homework.

class Types
{
   //No default constructor..
   Types(int Param1, int Param2);
};

class Objects
{
   public:
   Types* Original;

   Objects();
   ~Objects();
};

//The problem is here!

Objects::Objects()
{
   Original = new Types[100];   //I cannot do this.. I know that.. then what am I supposed to do?
}

Objects::~Objects()
{
  delete [] Original;
}


int main()
{
   Objects X;   //This is supposed to be dynamic.. I am not told how much records from a file it is supposed to hold.. so I though Fseek and tell would help me declare a size?

//Do I even need to do Root = new Types[100] or do I just do that for Objects X = new Objects[100];?
}

Can you use STL vectors?

Edit: Never mind I just read the title.

No.. I first used that.. then the guy I was helping, I told him how to use vectors/lists.. Apparently, they aren't allowed to use vectors either lol -_-

That's the sample the teacher gave them.. I found it odd that the size of the Objects X isn't told :S

Is the data in the file binary or lines of text?

Is the data in the file binary or lines of text?

Well For every line it represents one Record which is Why I thought of using Fseek or whatever to count the lines and then make an array of that size..

I have to be able to do:

int main()
{
   Objects X;
   X.pushback(...);   //basically add info to the object.
}

If you can't use STL, then you could make Objects a link list class.

commented: Good Suggestion.. You guess it right :) +6

If you can't use STL, then you could make Objects a link list class.

All of those suggestions tried already.. I cannot remove anything from the code posted above.. only allowed to add onto it.. I have no clue why just following instructions from the person I'm trying to help but failing miserably.

I solved it myself.. I did a lot of research and wrote linked lists and taught them linked lists.. Thanks for trying everyone who viewed/responded.

Edit: Never saw linked lists was suggested.. Thanks +1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.