struct and class in C++ are identical with the exception of their default visibility (private for class, public for struct). The struct keyword was a leftover from the C lineage of C++. That said, when a C++ compiler sees the struct keyword, it will compile it, but not in the same way that a C compiler would have. The C++ compiler will generate a default constructor, destructor, and copy-assignment operator (whereas a C compiler would just treat it as a new datatype).
They both exist in C++ because of the desire to be able to compile C code with a C++ compiler. Removing keywords such as this would have made such backwards-compatability impossible without first modifying the codebase.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
I'm putting together code for a template that implements some special tasks that I need and I want it to use with different CWnd based classes as template argument and ancestor at the same time like this:
template < class BASE >
class CLASS : public BASE
If I want to use it with CFormView and CDialog in the same project I need template argument dependent compiling, 'cause for example if I need to implement OnInitDialog() for CDialog, I must ignore it with CFormView, otherwise I get an error that this function is not the member of the base class.
I thought of doing string comparison of the BASE argument at the right places, but I'm not too familiar with macros.
#define STR_COMP(_base, _class) \
and use it as
#if STR_COMP(BASE, "CDialog")
#else if ...
Of course it doesn't work....
Maybe you should try a "specialization" of template classes? I suppose it may look like this:
template< class BASE >
class COMMON : public BASE
// common members for CDialog and CFormView base
. . .
template< class BASE >
class CLASS : public COMMON< BASE >
// nothing yet here
// specialization for CDialog:
class CLASS< CDialog > : public COMMON< CDialog >
// members specific to CDialog
. . .
// specialization for CFormView:
class CLASS< CFormView > : public COMMON< CFormView >
// members specific to CFormView
. . .
Hi to all,
I am compiling DirectX 9.0 SDK Sample Code Filter in VC6, it is compiling successfully. (Filter is DSNetwork Filter)
But when same code I compile in VC++ 2005, it is showing errors (as follows),
1. fatal error C1083: Cannot open source file: 'c:\DXSDK\Samples\C++\DirectShow\Filters\Change': No such file or directory c1
2. command line error MIDL1003 : error returned by the C preprocessor (2) midl
3. error PRJ0019: A tool returned an error code from "Performing Custom Build Step" dsnetifc
4. error BK1506 : cannot open file '.\Debug_Unicode\dsnetifc_i.sbr': No such file or directory BSCMAKE
5. error C2146: syntax error : missing ';' before identifier 'PVOID64' C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h 222
6. error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h 222
7. error C2146: syntax error : missing ';' before identifier 'Buffer' C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h 5940
Does anyone know a few tricks to make Edit controls behave like "smart labels"? That is; I want them to be read-only, but not have a caret. It's nice being able to copy the text using Ctrl+C, something which a simple static control cannot offer.
I assume there is a simple subclassing trick you can do. If you know it, feel free to tell me.