Common crashes & compile errors (C++)

This topic I will cover some common compile errors encountered in C++...
1. Error C2243: 'type cast' : conversion from 'DerivedClassXXX *' to 'BaseClassXXX *' exists, but is inaccessible.
Resolution: Most common cause is when deriving from your base class acces specifier keyword "public" might be missing
//Here is the code change in Bold
class DerivedClass : public BaseClass
{
///your code goes here
}
The C# touch: The "public" keyword used here to fix this issue is not applicable in C# environment. And also inheritance is always public by default there.
2. Program crashes on reading params from main()
Make sure correct overload is called. Below is one correct overload.
int main( int argc, char *argv[])
{
}
First param supplies number of arguments, make sure to check this one first.
Note: argv[0] will contain program's name with it's path.
For more clarity check this link below:
3. fatal error C1010: "unexpected end of file while looking for precompiled header directive" when compiling your win32 dll or exe
It can be as simple as not including stdafx.h file in to your cpp class implementation files. Other reasons visit :-) http://support.microsoft.com/kb/815644

No comments:

Post a Comment