struct entry
	{
		int key;
			
	} entry[TABLE_SIZE];

i declared a struc like this... but i no that u cant declare it in this way, if i write it in the correct way i am getting errors. Y is this, can some one modify this code please ..

i get errors if i write this in the following way ::::::

struct 
	{
		int key;
			
	} entry[TABLE_SIZE];

declare in .h:

struct entry_t
{
int key;
};

define in .cpp:

entry_t entry[TABLE_SIZE];

Otherwise multiple #inclusion of your .h will result in "multiply defined entry array" linker errors

In Visual C++ 2008 I don't get any errors, it works fine, using either way you've posted. Is there more to this than you're telling us?

What is the exact error message you get?

I would note, you are looking for problems in naming the struct type and the array of the struct the same as you do in your first example. I would have expected an error there.

In Visual C++ 2008 I don't get any errors, it works fine, using either way you've posted. Is there more to this than you're telling us?

What is the exact error message you get?

I would note, you are looking for problems in naming the struct type and the array of the struct the same as you do in your first example. I would have expected an error there.

this is the error
: error C2639: compiler generated default constructor required by unnamed class

declare in .h:

struct entry_t
{
int key;
};

define in .cpp:

entry_t entry[TABLE_SIZE];

Otherwise multiple #inclusion of your .h will result in "multiply defined entry array" linker errors

when i do it your way i get 56 errors ....

this is the error
: error C2639: compiler generated default constructor required by unnamed class

I think we need to see more of the program, because in isolation what you have seems fine.

This article has been dead for over six months. Start a new discussion instead.