| noktalivirgul (53) | |||||
|
I wrote a code to calculate tax of some vehicles with different properties.But it gives lots of errors. Please help me urgent :) my cpp file seems:
my header file seems:
| |||||
|
|
|||||
| NwN (770) | |
|
Hi there, Could you please post the errors along with the code? That makes it a lot easier for us to see what's going wrong. Thanks! All the best, NwN | |
|
|
|
| noktalivirgul (53) | |
|
thank you! 1> try 4.cpp 1>c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(5): error C2011: 'Poly' : 'class' type redefinition 1> c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(5) : see declaration of 'Poly' 1>c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(25): error C2011: 'commer' : 'class' type redefinition 1> c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(25) : see declaration of 'commer' 1>c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(40): error C2011: 'longv' : 'class' type redefinition 1> c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(40) : see declaration of 'longv' 1>c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(55): error C2011: 'privatev' : 'class' type redefinition 1> c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(55) : see declaration of 'privatev' 1>try 4.cpp(25): error C2079: 'commveh' uses undefined class 'commer' 1>try 4.cpp(26): error C2079: 'longveh' uses undefined class 'longv' 1>try 4.cpp(27): error C2079: 'privateveh' uses undefined class 'privatev' 1>try 4.cpp(40): error C2440: '=' : cannot convert from 'int *' to 'Poly *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>try 4.cpp(43): error C2039: 'setVarscomm' : is not a member of 'System::Int32' 1> c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::Int32' 1>try 4.cpp(44): error C2039: 'calculate_tax_commercial' : is not a member of 'System::Int32' 1> c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::Int32' 1>try 4.cpp(47): error C2440: '=' : cannot convert from 'int *' to 'Poly *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>try 4.cpp(50): error C2039: 'setVarslong' : is not a member of 'System::Int32' 1> c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::Int32' 1>try 4.cpp(53): error C2440: '=' : cannot convert from 'int *' to 'Poly *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>try 4.cpp(55): error C2039: 'setVarsprivate' : is not a member of 'System::Int32' 1> c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::Int32' 1> Generating Code... ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== | |
|
|
|
| NwN (770) | ||||
Hi there,
I believe these are called because you don't have any include guards in your header file:
That prevents the file from being included more than once, and thus the classes being "redefined". Try that, it could possibly solve the larger part of the other errors. Hope that helps. All the best, NwN | ||||
|
|
||||
| noktalivirgul (53) | |
|
thank you so much but it says: unable to start program, system coul not find the file. build errors: >c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(8): error C2011: 'Poly' : 'class' type redefinition 1> c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(8) : see declaration of 'Poly' 1>c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(28): error C2011: 'commer' : 'class' type redefinition 1> c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(28) : see declaration of 'commer' 1>c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(43): error C2011: 'longv' : 'class' type redefinition 1> c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(43) : see declaration of 'longv' 1>c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(58): error C2011: 'privatev' : 'class' type redefinition 1> c:\users\hp\documents\visual studio 2010\projects\try 4\try 4\try4class.h(58) : see declaration of 'privatev' 1>try 4.cpp(25): error C2079: 'commveh' uses undefined class 'commer' 1>try 4.cpp(26): error C2079: 'longveh' uses undefined class 'longv' 1>try 4.cpp(27): error C2079: 'privateveh' uses undefined class 'privatev' 1>try 4.cpp(40): error C2440: '=' : cannot convert from 'int *' to 'Poly *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>try 4.cpp(43): error C2039: 'setVarscomm' : is not a member of 'System::Int32' 1> c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::Int32' 1>try 4.cpp(47): error C2440: '=' : cannot convert from 'int *' to 'Poly *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>try 4.cpp(50): error C2039: 'setVarslong' : is not a member of 'System::Int32' 1> c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::Int32' 1>try 4.cpp(53): error C2440: '=' : cannot convert from 'int *' to 'Poly *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>try 4.cpp(55): error C2039: 'setVarsprivate' : is not a member of 'System::Int32' 1> c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::Int32' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== | |
|
|
|
| jlb (169) | |
|
Did you make the changes suggested it the previous post? If so please re-post the contents of your include file. | |
|
|
|
| NwN (770) | |
|
Hi, Are you sure that #include "try4class.h" :1) is called try4class.h? 2) is in the same directory as the .cpp file? All the best, NwN | |
|
|
|
| noktalivirgul (53) | |
| yes i am sure :) | |
|
|
|
| NwN (770) | |||
-N | |||
|
|
|||
| noktalivirgul (53) | |
|
i did some corrections but the only error is the system cannot find the file. error: 1>c:\users\hp\documents\visual studio 2010\projects\try5\try5\stdafx.h(10): fatal error C1083: Cannot open include file: 'try4class.h': No such file or directory ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== | |
|
|
|
| jlb (169) | |
| Did you add try4class.h to the stdafx.h header? If so I would remove it from there. Just keep the include in your .cpp file | |
|
|
|
| noktalivirgul (53) | |
|
no it is not included to stdafx. only in cpp. but i tried both :) | |
|
|
|
| jlb (169) | |
|
This sounds like an issue with the pre-compiled headers because the compiler is complaining about stdafx.h not being able to find your include file. You may want to try turning off this feature and commenting out stdafx.h and see if that helps. | |
|
|
|