Visual C++ Studio 2010 error C2011 help

i have no idea whats wrong with this

Add_Item.h(form2):
http://codepad.org/ZNiqXms1
Form1.h:
http://codepad.org/qjYgQMon
Add_Item.cpp:
http://codepad.org/HV05TpuW
Code_Manager_Cl.cpp:
http://codepad.org/hHGRuHMU

Debug Data:
1
2
3
4
5
6
7
8
9
10
1
1>  Add_Item.cpp
1>c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\code_manager_cl\Add_Item.h(16): error C2011: 'Code_Manager_Cl::Add_Item' : 'class' type redefinition
1>          c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\debug\code_manager_cl.exe : see declaration of 'Code_Manager_Cl::Add_Item'
1>  Code_Manager_Cl.cpp
1>c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\code_manager_cl\Add_Item.h(16): error C2011: 'Code_Manager_Cl::Add_Item' : 'class' type redefinition
1>          c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\debug\code_manager_cl.exe : see declaration of 'Code_Manager_Cl::Add_Item'
1>c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\code_manager_cl\Form1.h(17): error C2011: 'Code_Manager_Cl::Form1' : 'class' type redefinition
1>          c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\debug\code_manager_cl.exe : see declaration of 'Code_Manager_Cl::Form1'
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Mind telling us more about the problem? What did you do last that caused this? What have you tried changing already?
Please read the error message! Do you have not understood? Then the second time please read the error message and do not bother members of forum next time!
MSVCE10 wrote:
'Code_Manager_Cl::Add_Item' : 'class' type redefinition
see declaration of 'Code_Manager_Cl::Add_Item'


This means you're redeclaring your class over and over again.
Then the second time please read the error message and do not bother members of forum next time!

Hey podruga, take a chill pill.
Then again, this looks like C++/CLI code... so this forum might indeed not be the best place to ask questions.
Looks like Win32 API to me with forms and such...I think this is another reason why VS is the devil. Everyone gets it and automatically thinks they know how to program, but they get simple errors and can't figure out what they did wrong.
This is no Win32 I've seen. I agree that this is CLI, or C++.NET /shudder
Looks like Win32 API to me with forms and such...

Did you see this?
1
2
3
4
5
6
7
8
9
10
11
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}

No I did not, I didn't even look at the code once I saw all the errors. I noticed the Form in Form1.h and assumed, my bad.
Please read the error message! Do you have not understood? Then the second time please read the error message and do not bother members of forum next time
I took a high school c++ class and havent used c++ for months so yes in a little confused. ,

how am i declaring it over and over again? or where i should be asking.

and this is C++ .net .

Looks like Win32 API to me with forms and such...I think this is another reason why VS is the devil. Everyone gets it and automatically thinks they know how to program, but they get simple errors and can't figure out what they did wrong.


I never said i know how to program i only know a little bit and am trying to further my learning in c++ because it is somthing i like and want to eventually want to get a job in programming.

~Thanks all
Word of personal advice, avoid C++.net. If you wanna use .net, use C#. If you want c++, then use the standard c++. I think others here will agree with me as well
Thats good to know , but can someone please tell me where and/or how am i re declaring the class over and over again?
I see these lines in two of your header files...
1
2
3
4
5
6
7
8
namespace Code_Manager_Cl {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;


You also call Add_Item.h in three of the files. This is the purpose of the stdafx.h. You put ALL of your #includes in there, it's like an all purpose header file. You're also using the header guards incorrectly. You aren't supposed to use the header guards within a .cpp, only within a .h/.hpp

Like I said, I think you should learn more about the basic use of the language before attempting something that's way above your head.
Last edited on
If you can zip the project and upload it somewhere I can take a close look, but at first glance the only thing I see is the header guards look weird.
I see these lines in two of your header files..
1
2
3
4
5
6
7
8
namespace Code_Manager_Cl {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;



You also call Add_Item.h in three of the files. This is the purpose of the stdafx.h. You put ALL of your #includes in there, it's like an all purpose header file. You're also using the header guards incorrectly. You aren't supposed to use the header guards within a .cpp, only within a .h/.hpp

Like I said, I think you should learn more about the basic use of the language before attempting something that's way above your head.


ok so i included Add_Item in stdafx.h., that only got rid of half of the problom
1
2
3
4
1
1>  stdafx.cpp
1>c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\code_manager_cl\Add_Item.h(16): error C2011: 'Code_Manager_Cl::Add_Item' : 'class' type redefinition
1>          c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\debug\code_manager_cl.exe : see declaration of 'Code_Manager_Cl::Add_Item'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


if i add Form1.h to stdafx.h i get the original error., how do i fix this?

stdafx.cpp:
http://codepad.org/Q5ccNlsM

stdafx.h:
http://codepad.org/onD0mOae

Form1:
http://codepad.org/bQD2NW0j

Add_Item:
http://codepad.org/l0vFzG1N

main cpp:
http://codepad.org/ErQk2kaI

Add_Item.cpp:
http://codepad.org/6DNQ4qDB

assembly info.cpp:
http://codepad.org/w4IOienO
Your error specifically says that in file stdafx.cpp you are redeclaring the Code_Manager_1::AddItem class member. This means that not only are you declaring it in that file, but also somewhere else in your file. This is why I said you should learn more about the basics rather than just jumping into something.
I ran your code and was not able to reproduce the error. Maybe recreate the project?
Your error specifically says that in file stdafx.cpp you are redeclaring the Code_Manager_1::AddItem class member. This means that not only are you declaring it in that file, but also somewhere else in your file. This is why I said you should learn more about the basics rather than just jumping into something.


it will not let me include Form1.h to Code_Manager_Cl.cpp , and Add_Item.h to Add_Item.cpp. and they are not declared anywhere else and that is where they are supposed to be included so i dont know why im getting the error.

EDIT:
when i include Add_Item.h to stdafx.h the Form1.h Redeclaring error goes away. and vice versa for incluing Form1.h to stdafx.h.

error before adding anything to stdafx.h:
1
2
3
4
5
6
7
8
9
10
1
1>  stdafx.cpp
1>  Add_Item.cpp
1>c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\code_manager_cl\Add_Item.h(16): error C2011: 'Code_Manager_Cl::Add_Item' : 'class' type redefinition
1>          c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\debug\code_manager_cl.exe : see declaration of 'Code_Manager_Cl::Add_Item'
1>  AssemblyInfo.cpp
1>  Code_Manager_Cl.cpp
1>c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\code_manager_cl\Form1.h(23): error C2011: 'Code_Manager_Cl::Form1' : 'class' type redefinition
1>          c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\debug\code_manager_cl.exe : see declaration of 'Code_Manager_Cl::Form1'
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Error after adding Add_Item.h:
1
2
3
4
1
1>  stdafx.cpp
1>c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\code_manager_cl\Add_Item.h(16): error C2011: 'Code_Manager_Cl::Add_Item' : 'class' type redefinition
1>          c:\users\owner\desktop\my shit\my shit\code stuff\code stuff\hack,codeing stuff\recreate programs\code_manager_cl\debug\code_manager_cl.exe : see declaration of 'Code_Manager_Cl::Add_Item'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on
Topic archived. No new replies allowed.