|
toxcct wrote: no. friend functions/classes access at most protected members (and of course public ones), but not private.
Wrong, it can access also private members (otherwise, this would be stupid): source[^]
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
|
What was there inside the MSDN? I think there is nothing saying in MSDN about a friend function accessing private and public or protected!!!
SaRath.
"Don't Do Different things... Do Things Differently..."
Understanding State Pattern in C++
|
|
|
|
|
From MSDN:
In some circumstances, it is more convenient to grant member-level access to functions that are not members of a class or to all functions in a separate class. The friend keyword allows a function or class to gain access to the private and protected members of a class. You can declare friend functions or friend classes to access not only public members but also protected and private class members.
Check it here!!![^]
SaRath.
"Don't Do Different things... Do Things Differently..."
Understanding State Pattern in C++
|
|
|
|
|
Uh . I just posted this link in the post above...
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
|
and what does the last sentence you quoted means for you ???
"You can declare friend functions or friend classes to access not only public members but also protected and private class members."
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Thanks for responding.
I have declared function in class decalaration like this
class date <br />
{<br />
private:<br />
....
....<br />
....<br />
public:<br />
date(int=1, int =1, int =1900);<br />
friend ostream& operator<<(ostream& , date&);<br />
}
Now i define this function is .cpp file like this
ostream& date::operator<<(ostream&o, date& a)<br />
{<br />
o<<year<<month<<day<<endl;<br />
return o;<br />
}
but it gives me this error,
error C2039: '<<' : is not a member of 'date'
Why this error is occuring?
Thanks
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
|
Sorry toxcct, I could not get your point. Can you please explain it? Thank you.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
|
The operator<< function is a friend of your class thus it is not a member of the class.
Change the definition into:
ostream& operator<<(ostream&o, date& a)<br />
{<br />
...<br />
}
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Another thing I didn't see when I first read your post :
The first argument of the operator has to be a stream (cause it is the part which is on the left of the operator). Thus You can't make it a member of the CMyClass class. You have to make it a global function.
So, the solution is to declare the prototype in the header file of CMyClass (but outside the class) and then use this definition:
ostream& operator << (ostream& os, date& d)
{
return os;
}
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hi All,
I got a problem in creating popup...Can anyone tell me how to get popup window or menu while right clicking the mouse button in a ListCtrl..
thanks in Advance
With regards
Raja Bose
-- modified at 6:43 Thursday 8th June, 2006
|
|
|
|
|
|
Next, if your problem is to display a menu, try TrackPopupMenu or TrackPopupMenuEx members of CMenu class.
|
|
|
|
|
SaRath C wrote: Add message handler for NM_RCLICK
why not for WM_CONTEXTMENU ?
nave
|
|
|
|
|
yes WM_CONTEXTMENU of course with one if.if hwnd==m_list.hwnd
whitesky
|
|
|
|
|
See like this
<br />
void CAnswerDlg::OnNMRclickList1(NMHDR *pNMHDR, LRESULT *pResult)<br />
{<br />
HMENU hmenu,hmenuPopup;<br />
CPoint point;<br />
GetCursorPos(&point);<br />
hmenu = LoadMenu(AfxGetApp()->m_hInstance,(LPCTSTR) IDR_MENU1); <br />
hmenuPopup = GetSubMenu(hmenu, 0); <br />
TrackPopupMenu(hmenuPopup, TPM_LEFTALIGN | TPM_LEFTBUTTON, <br />
point.x,point.y, 0,m_List1.m_hWnd, NULL); <br />
DestroyMenu(hmenu); <br />
*pResult = 0;<br />
}<br />
whitesky
|
|
|
|
|
Dear guys,
I am trying to build an application using OMAKE,
the error is "fatal error RC1109: error creating TusMsvFE.res"
what could be the reason ?
Velayudhan
|
|
|
|
|
make sure that the file is not read only. that may be a reason for this.
SaRath.
"Don't Do Different things... Do Things Differently..."
Understanding State Pattern in C++
|
|
|
|
|
no , file is not read only
but when i deleted the tusmsvfe.res file from the folder and then builded, no error is there.
But again, when I modify resource, error comes,
what may be the reason ?
|
|
|
|
|
When I modify string like this
\nExts\nExts\nMyDocTypes(*.aaa;*.bbb)\n.aaa;.bbb\nExts.Doc\nExts Doc
then in "FileOpen" dialog file types are displayed:
MyDocTypes (*.aaa, *.bbb)
And I'd like it to be displayed like when I'm creating "FileOpen" dialog by myself - then file types are displayed like this:
MyDocType1 (*.aaa)<br />
MyDocType2 (*.bbb)<br />
MyDocType3 (*.ccc)<br />
MyDocType4 (*.ddd)<br />
All files (*.*)
How could I do this? )
~~~~
-- modified at 6:07 Thursday 8th June, 2006
|
|
|
|
|
I think it should be:
"MyDocType1 (*.aaa)\0*.aaa\0MyDocType2 (*.bbb)\0*.bbb\0MyDocType3 (*.ccc)\0*.ccc\0MyDocType4 (*.ddd)\0All files (*.*)\0*.*\0";
this is this.
|
|
|
|
|
See Here[^] maybe it is some helpful to you
whitesky
|
|
|
|