|
Not that much.
The principle "It sis yopur software, but that's not your computer" was applied by the US court that made Sony BMG retire their own "copyright protection systems" and pay some billions in a class action.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
How could I find spefications of C++ operators overload, such as how many arguments should operator+() take, what should be the first operator of operator new(), operator int() qualifies only if it's a member function.
I have <<c++ primer="">>, it lists a few of them.But it doesn't satisfy my needs.could someone help me?
|
|
|
|
|
Does this[^] help?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Without googling for possibly more concise information, I do recall one thing about operator overloads: They must fit the signature of the standard operation; not with respect to type, which may be different, but with respect to number of arguments. Some operators have more strict requirements, e. g. assignmen operators should always return a value of type 'reference to the type that is being assigned to', but AFAIK these are not enorced by the compiler. It is still strongly recommended because otherwise youmight get unexpected behaviour when using these types with template libraries such as the STL.
You could take a look at the interface of std::complex for a comprehensive list of overloaded operators and their signatures: complex operators
P.S.: operator int() and the like, i. e. the casting operators, have their own special syntax:
a) they may not have a return type (which would be redundant anyway), and
b) they don't take an argument, because - as you noted - they only work as member functions.
You should however consider to specify them as explicit , to prevent an accidental inappropriate use through automatic type conversion by the compiler.
|
|
|
|
|
Hi Developers,
I was facing "Memory Leak" problem, from this chunk of code.
I have allocate a memory for a structure( pRecStruct ) & after that it has stored in a map( CMapWordToPtr - pMapUserBoard ) for furher use.
I have tried to delete as well, but the next time if i am trying to use.
Plese tell me the issue.
if( bSymAlreadyPresent == false )
{
CString str(pDBStruct->Symp);
strTemp.Format( _T("%d"), userClipIndx + 1 );
str += " Symptom Dropped on Clipboard " + strTemp;
MessageBox( NULL, str, "", MB_OK );
NEWDB_STRUCT near *pRecStruct=NULL;
pRecStruct=new NEWDB_STRUCT;
int cLen=strlen(pDBStruct->Symp);
pRecStruct->Symp=new char[cLen+1];
memset(pRecStruct->Symp, NULL,cLen+1);
memcpy(pRecStruct->Symp,pDBStruct->Symp,cLen);
pRecStruct->Remedy=new char[strlen(pDBStruct->Remedy)+1];
memset(pRecStruct->Remedy, NULL,strlen(pDBStruct->Remedy)+1);
memcpy(pRecStruct->Remedy,pDBStruct->Remedy,strlen(pDBStruct->Remedy));
pRecStruct->RecSize=pDBStruct->RecSize;
pRecStruct->LevelNum=pDBStruct->LevelNum;
pRecStruct->RemedyCnt=pDBStruct->RemedyCnt;
iTemp = pMapUsrClipboard->GetCount();
pRecStruct->SymNo = iTemp;
pRecStruct->Author=pDBStruct->Author;
pRecStruct->RecNo=pDBStruct->RecNo;
pRecStruct->ParOffset=pDBStruct->ParOffset;
pRecStruct->NextOffset=pDBStruct->NextOffset;
pRecStruct->CurOffset=pDBStruct->CurOffset;
pRecStruct->SymType=0;
pMapUsrClipboard->SetAt( iTemp, pRecStruct ); /// for remedies
/* delete pRecStruct;
pRecStruct = NULL;*/
bResult = true;
//clip1++;
}
Thanks.
Amrit Agrawal
Software Developer.
|
|
|
|
|
Amrit Agr wrote: I have tried to delete as well, but the next time if i am trying to use.
That isn't clear. What do you mean?
However you should know you need to delete the allocated character arrays together with the struct itself. You may use the destructor for this task:
struct RectStruct
{
RectStruct()
{
Symp = NULL;
Remedy = NULL;
}
~RectStruct()
{
if (Symp) delete [] Symp;
if (Remedy) delelte [] Remedy;
}
};
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Friend,
ur question not clear.
Tho i assume u face memory leak problem. and i suggeset watever u doing is rite. that is u delete the pointer and assign it to null.
Arun P.
|
|
|
|
|
Amrit Agr wrote: I have tried to delete as well...
You've not shown any code that deletes.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I meant this in ur code.
you hav commented this!
delete pRecStruct;
pRecStruct = NULL;
on using this also you face the problem?.
Arun P.
|
|
|
|
|
How to load dll in pure C++ class?
|
|
|
|
|
What do you really mean?
You know there's a function, namely LoadLibrary[^] to (explicitely) load a dynamic library.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The question isn't very clear, I'm afraid.
If you use "pure C++" to mean only standards-compliant language elements/libraries, the answer is that you can't. To start with, DLL files are specific for the Windows platform, so any solution would not work on Unix/Linux/MacOS etc.
If you are concerned that the Windows function to load a DLL (LoadLibrary , as already noted) is a C function, and therefore should not for some reason be used in "pure C++", don't worry - a large reason for making C++ backwards compatible with C was that many operating systems offer their native APIs as C functions, and calling them is a perfectly valid use of C++.
|
|
|
|
|
Here is an exception-free way :
class CSafeDllHolder {
HMODULE m_hModule;
public:
CSafeDllHolder(LPCTSTR lpszLib) : m_hModule(::LoadLibrary(lpszLib)) {}
~CSafeDllHolder() { if (m_hModule) ::FreeLibrary(m_hModule); }
HMODULE GetHandle() const { return m_hModule; }
};
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Hello,
Can you please explain me what is mfc100u.lib and its got to do with VS2010?
Thanks.
|
|
|
|
|
1. Drag-select "mfc100u.lib" in your last post
2. Right-click, select "Search Google for mfc100u.lib"
3. click 2nd search result.
It took less time than reading your question. Presumably I can read your question quicker than you can type it?!
|
|
|
|
|
Hi,
I need to add worksheets(like sheet2,sheet3,...) with the below exising code. Now sheet1 is coming by default and able to write the contents.
Existing Code:
--------------
COleException objEx; // exception object
Application objExcel; // excel application object
// local var
COleVariant vRet;
// row index
long nRow = 1;
// range object
Range objRange;
// create the excel object
objExcel.CreateDispatch( "Excel.Application", &objEx );
// show the application
objExcel.SetVisible( COleVariant(short(FALSE)) );
// get the workbooks object
vRet = objExcel.Workbooks2();
// set the workbooks object
Workbooks objWorkbooks( V_DISPATCH( (LPVARIANT)vRet ) );
// adding the new workbook
vRet = objWorkbooks.Add( COleVariant( (long)xlWorksheet ) );
// set the workbook object
Workbook objWorkbook( V_DISPATCH( (LPVARIANT)vRet ) );
// adding the worksheet
vRet = objWorkbook.Worksheets( COleVariant( (long)1 ) );
// set the worksheet object
Worksheet objWorksheet( V_DISPATCH( (LPVARIANT)vRet ) );
How to add more sheets with the above code? Please help.
I am using below header files;
#include "XL5EN32.H"
#include "excel9.h"
#include "ExcelObject.h"
Thanks,
Pala
|
|
|
|
|
Did you try this[^] class ?
|
|
|
|
|
I have the follow code :
#if _MSC_VER > 1200
BOOL CMainFrame::ShowNotifyBaloon(LPCTSTR lpszBalloonTitle, LPCTSTR lpszBalloonMsg, DWORD dwIcon, UINT nTimeOut)
{
ASSERT (dwIcon == NIIF_WARNING || dwIcon == NIIF_ERROR || dwIcon == NIIF_INFO || dwIcon == NIIF_NONE);
NOTIFYICONDATA nid = {sizeof(NOTIFYICONDATA)};
nid.uID = 0;
nid.hWnd = m_hWnd;
nid.dwInfoFlags = dwIcon;
nid.uFlags |= NIF_INFO;
nid.uTimeout = nTimeOut;
nid.uCallbackMessage = WMU_TRAYNOTIFYICON;
::strcpy(nid.szInfoTitle,lpszBalloonTitle);
::strcpy(nid.szInfo,lpszBalloonMsg);
return ::Shell_NotifyIcon(NIM_MODIFY,&nid);
}
#endif // _MSC_VER > 1200
ShowNotifyBaloon(_T("Info"),_T("Test message"),NIIF_INFO,5);
and the ShowNotifyBaloon method is calling because I verify that through a TRACE macro, but still, I don't see any baloon in system tray ( I have to mention that application is minimized in system tray ).
What I'm doing wrong ?
modified on Saturday, September 3, 2011 10:12 AM
|
|
|
|
|
I see that you're not setting the size member of the structure:
nid.cbSize = sizeof( NOTIFYICONDATA );
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thank you for feedback, I will try what you said, but right now I haven't newer environment then VC6 ... Thank you.
|
|
|
|
|
Technically, he is with the initializer
NOTIFYICONDATA nid = {sizeof(NOTIFYICONDATA)}; but it only works because the .cbSize element is offset 0. This is bad programming practice. Doublly so since he responded to your suggestion with "I will try what you said", meaning that he didn't know he was initializing it, probably somebody else's code he's trying.
Best practices would the to explicitly initialize the structure like this
NOTIFYICONDATA tnid;
memset(&tnid, 0, sizeof(tnid));
tnid.cbSize = sizeof(NOTIFYICONDATA);
tnid.hWnd = GetSafeHwnd();
etc...
|
|
|
|
|
Chuck O'Toole wrote: Technically, he is with the initializer
Wow, learn something every day. I didn't realize that's what that code does.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Did you also ever create the notify icon by calling Shell_NotifyIcon with NIM_ADD.
See this MSDN page[^] for a technical description of the function.
|
|
|
|
|
Yes, of course, I have already icon in system tray. I just want to setup NIM_MODIFY parameter to show up a baloon notification.
|
|
|
|
|
Does the code work if you make the proposed modification of explicitly setting cbSize, along with the following: nid.uFlags = NIF_INFO; rather than |= which can (and I think in this case does) lead to errors?
|
|
|
|