Pointers and arrays

1
2
3
4
5
SubassemblyType::SubassemblyType(char *city)
{
	ident=city;
	state=START;
}

1
2
3
4
5
6
for(int i=0; i<nobjects;i++)
	{
		fin >> city;
		components[i] = new SubassemblyType(city);
		
	}

I'm currently using this for loop to construct SubassemblyTypes within the array components(declared as SubassemblyType**)

The main problem i'm running into is that, upon inspection of all the values of ident, they are all the last value read in from the file fin. All of the values are being read, i know that, but it's assigning all the ident values to the same char array
Last edited on
Topic archived. No new replies allowed.