|
When you make a binary operator a member of the class, it only takes one parameter. The left-side parameter is this .
class CTimeCode
{
public:
CTimeCode operator+ ( const CTimeCode rhs ) const
{
CTimeCode ret;
ret.m_lTimeCode = m_lTimeCode + rhs.m_lTimeCode;
return ret;
}
};
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
Anonymous wrote:
const CTimeCode CTimeCode:perator+ (const CTimeCode &TimeCode1, const CTimeCode &TimeCode2)
{
CTimeCode &TimeCodeResult;
TimeCodeResult.m_lTimeCode = TimeCode1.m_lTimeCode + TimeCode2.m_lTimeCode;
}
You just need one parameter wich is the second operand of the +. The first operand is this class (you can access it using the this keyword).
So change your function to this:
const CTimeCode CTimeCode:operator+ (const CTimeCode &TimeCode)<br />
{<br />
CTimeCode &TimeCodeResult;<br />
TimeCodeResult.m_lTimeCode = this.m_lTimeCode + TimeCode.m_lTimeCode;<br />
<br />
return TimeCodeResult;<br />
}
|
|
|
|
|
Huum ok, yes the this is not an obligation (sorry, little bit tired today ). Of course, you can access directly your class members...
|
|
|
|
|
And how to initialize "CTimeCode &TimeCodeResult" ?
|
|
|
|
|
Don't you have a default constructor ??
|
|
|
|
|
you also forgot to return a value from you operator+()
TOXCCT >>> GEII power
|
|
|
|
|
Generally I would implement:
class CTimeCode
{
CTimeCode& operator+=( const CTimeCode& rhs )
{
m_lTimeCode += rhs.m_lTimeCode;
return *this;
}
};
CTimeCode operator+( const CTimeCode& lhs, const CTimeCode& rhs )
{
CTimeCode ret( lhs );
ret += rhs;
return ret;
} Using a global- or namespace-scope operator+ allows conversions to happen on both operands (say, if you have a conversion operator or a single-operand constructor) whereas a class member only allows conversion on the right-hand operand.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
i'm really tired of manual converting which make me doubt whether am i a man or a machine.
thx
|
|
|
|
|
|
Hi,
I have SDI app that load files through CWinApp::OnFileOpen.
When the file dialog opens it is in the last opened directory. Normally this is the wrong directory.
When My program starts and File open is selected I want it to open in my default directory.
How can I set this without overriding OnFileOpen and using a CFileDialog
Thanks
---
|
|
|
|
|
You could override CDocManager::DoPromptFileName , but bear in mind that CDocManager is an undocumented class and could change.
Note that Windows itself is providing this default behaviour, which users may have come to expect from their other applications. See the documentation for the OPENFILENAME structure's lpstrInitialDir member (MSDN Library[^]).
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Mike Dimmick wrote:
You could override CDocManager::DoPromptFileName
Yep thats what I have done,
and that works fine (as long as CDocManager doesnt change)
Thanks
---
|
|
|
|
|
Anybody been able to get CLSID_WebBrowser to work without having to use MFC and ATL but instead with CoCreateInstance? Mainly, the problem I see is that Navigate or Navigate2 seems to fail.
My code looks something like this:
//hr = CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER, IID_IWebBrowser2, (void**)&Browser);
hr = CoCreateInstance(CLSID_WebBrowser, NULL ,CLSCTX_INPROC, IID_IWebBrowser2, (void**)&Browser);
CLSID_InternetExplorer seems to work fine but the only problem is I cannot query IHTMLElementRender which is a problem because I want to do a SaveToDC. I can query IHTMLElement perfectly fine though. Here's some more code I have on that.
if (FAILED(hr) || (HtmlElement == NULL))
{
printf("Error: IHTMLDocument2::get_body failed\n");
return FALSE;
}
hr = HtmlElement->QueryInterface(IID_IHTMLElementRender, (void**)&HtmlRender);
if (FAILED(hr) || (HtmlRender == NULL))
{
printf("Error: Unable to QueryInterface for IID_IHTMLElementReader\n");
return FALSE;
}
Has anybody else had this problem? I've checked all over the web and have found little for using CoCreateInstance in conjunction with IHTMLElementRender.
Thanks,
Nathan
Nathan
|
|
|
|
|
What's the return value of CoCreateInstance in this case?
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
hiiii
i want that somebody give me code to get the RGB values from an image and show in edit boxes.
somebody told me use GetRValue , GetRValue , GetRValue by using GetPexil method but i don't know how to do it.
its a bit urgent plz
regards
tahir
|
|
|
|
|
GetPixel() with :
GetRValue()
GetGValue()
GetBValue()
TOXCCT >>> GEII power
|
|
|
|
|
Hi,
Is DDE still being use in programms, or is some thing newer? Is any examples of DDE (or newer thing) availabel some where?
Thanksing
|
|
|
|
|
quzi wrote:
Is DDE still being use in programms...
Yes, the clipboard uses it, or at least it used to in earlier versions of Windows. A cursory glance at the documentation indicates it probably still does.
quzi wrote:
...or is some thing newer?
There are a variety of IPC mechanisms, such as COM, Mailslots, Pipes, and RPC, just to name a few.
quzi wrote:
Is any examples of DDE (or newer thing) availabel some where?
Here is but one. Try Googling for others.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Use of DDE is discouraged on Windows Server 2003.
The DDE is a gaping security hole, as I understand it.
You are supposed to use the Micosoft Message Queue, or the other methods as David suggested.
|
|
|
|
|
hi all,
i need a good "send email sample" of vc for my project,
i do have few samples in hand, but none of them can be tested properly.
thx for any links
includeh10
|
|
|
|
|
Try this one: http://www.naughter.com/smtp.html
Very simple to use (nice C++ interface), and it even supports attachments, MIME, and some authentication protocols. Works very nicely for me.
Best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
do u mean from MFC menu "send"?
i need seed email programmtically.
user does not need to use interface, all from reading files (email address and message)
includeh10
|
|
|
|
|
Check Dominik's post again. Did you notice the link he provided? It is a class for programmatically sending e-mail via SMTP. You can also find examples here.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Dominik and DavidCrow,
thanks. i downloaded a sample before which has the same name as your sample - an exe active control for VB - i don't know VB.
but this sample is totally wonderful, i think it is exactly what i need.
one Q:
when i run the program, it asks for configuration - host name/address, is it my PC's ip address?
thanks again.
includeh10
|
|
|
|
|
includeh10 wrote:
it asks for configuration - host name/address, is it my PC's ip address?
Only if your PC is also the host.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|