|
right.
template < struct T > class nope {...}; = bad
|
|
|
|
|
Default inheritance type: a struct entails public inheritance by default whereas a class entails private inheritance.
Regards
Amar
|
|
|
|
|
Subramaniam s.V. wrote:
Can anybody tell me the exact "Difference between C++ Structures and C++ Classes".
This is discussed in The Design and Evolution of C++.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
About differences. The default protection in case of class is "private ", whereas in case of struct it is "public ":
class A
{
int a;
. . .
};
struct A
{
int a;
. . .
};
The default inheritance protection in case of class is "private ", whereas in case of struct it is "public ":
class B : A
{
};
struct B : A
{
};
That’s my opinion about differences.
|
|
|
|
|
|
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
Zac
|
|
|
|
|
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) \
(strcmp(#_base, _class)==0)
and use it as
#if STR_COMP(BASE, "CDialog")
.....
#else if ...
....
#else
...
#endif
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
{
. . .
};
template< class BASE >
class CLASS : public COMMON< BASE >
{
};
template< >
class CLASS< CDialog > : public COMMON< CDialog >
{
. . .
};
template< >
class CLASS< CFormView > : public COMMON< CFormView >
{
. . .
};
Usage:
CLASS< CDialog > dlg;
CLASS< CFormView > form;
I hope this works.
|
|
|
|
|
I already figured but thanks, anyway.
Anybody dealing with the same issue should know to have all the specialized functions inline in the header file if want to get rid of LNK2006 errors..
|
|
|
|
|
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
& many more..
plz. help me.
Thanks & Best Regards,
Aniket Salunkhe
|
|
|
|
|
Try this:
Go to Tools->Options->Project and solutions -> VC++ Directories
Show library files -> Library files
At top include
D:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release(or Debug)
at last
D:\DXSDK\lib
Show library files -> Include files
At last
D:\DXSDK\Include\DShowIDL
D:\DXSDK\Include
D:\DXSDK\Samples\C++\DirectShow\BaseClasses
Regards
Amar
|
|
|
|
|
pls help me for the sln
how to find out
whether the Directory is persent or Not(C drive or D Drive)
is there any API available in C++?
|
|
|
|
|
What exactly u want. To find the Directory or Drive?
Come online at:-
fitiyal@yahoo.com
|
|
|
|
|
1)To find the Drive?
2) To Find out Directory?
|
|
|
|
|
Use FindFirstFile()
Come online at:-
fitiyal@yahoo.com
|
|
|
|
|
You can use good old _stat() or _access()
|
|
|
|
|
use
PathFileExists()
nave
|
|
|
|
|
Use GetFileAttributes() to determine the presence of a file or directory.
|
|
|
|
|
See
<br />
BOOL o=PathFileExists("d:\\mp");
WIN32_FIND_DATA lp;<br />
<br />
HANDLE handle=FindFirstFile("d:\\mp",&lp);
CloseHandle(handle);<br />
|
|
|
|
|
Hello
i work on CTI sofwtare with TAPI 3 and i catch all events from a line.
But, i have a HRESULT fail on the get_CallInfoString function when there are a event:
function used for Event form TAPI_EVENT.TE_CALLINFOCHANGE:
private void OnCallInfoEvent(ITCallInfoChangeEvent pEvent)
{
try....
string callerIDName = pEvent.Call.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME);
string callerIDNumber = pEvent.Call.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER);
catch....
finally
}
Thanks Jerome
|
|
|
|
|
Hello,
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.
--
Behold, for I am THE CORRUPTOR!
|
|
|
|
|
What about the other way round, implement copy operation on a CStatic ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
How do you select text in a static?
--
Behold, for I am THE CORRUPTOR!
|
|
|
|
|
Hi,
I have a give a CString value from one class to Editcontrol of another class.
Example- In GrpView.cpp,
CString Strnum = "123";
I have to put this value in Dialog.cpp ,in Edit control of that particular dialog.
Can we do this like this,Is there any way?Pls help me
Anu
|
|
|
|