|
|
Hello everyone,
The following code,
operator const Outer::Inner * volatile & ();
1.
I think it means an operator &, which returns const Inner* type and takes no arguments, right?
2.
Adding volatile to return value means?
(I previously only used volatile to qualify variable)
thanks in advance,
George
|
|
|
|
|
George_George wrote: 1.
I think it means an operator &, which returns const Inner* type and takes no arguments, right?
I believe it is not an & operator returning const Inner* type, you can ensure this by writting code as follows
const Inner* pInner = &objOuter\\ object of Outer or the class within which the operator is defined
error C2440
The prototype of function that matches your guess will be
const Outer::Inner * operator &();
It is actually a type cast operator that type casts to const Inner *, const Inner * &, a reference to pointer to const Inner type object
Iam not sure about the volatile qualifier in the return type, I think it gives the caller of the function the detail that the returning reference variable is volatile
|
|
|
|
|
Thanks Rajkumar_R,
You mean convert from current type to const Inner * & type (a reference to pointer to const Inner type object), right?
regards,
George
|
|
|
|
|
Yes,
Let the Class Outer has the specfied operator
then if this typecast is applied to the Outer class object (current type is Outer), the specified operator function is called.
Outer OuterObj;
const Outer::Inner * innerObj = (const Outer::Inner * )(OuterObj);
or
const Outer::Inner * &innerObj = (const Outer::Inner * &)(OuterObj);
note the operator returns the inner object rather than binary interpretting the object in memory like C-style casting (power of operator overloading)
|
|
|
|
|
Thanks Rajkumar_R,
Your reply is great! Your samples verified one thing, in C++ compiler does not distinguish reference and object type itself. Right?
regards,
George
|
|
|
|
|
Rajkumar_R wrote: const Outer::Inner * innerObj = (const Outer::Inner * )(OuterObj);
This does not compile.
Rajkumar_R wrote: const Outer::Inner * &innerObj = (const Outer::Inner * &)(OuterObj);
This compiles, but the member operator function is not invoked.
My modification below.
class O
{
public:
class I
{ } m;
const I* operator &() {
printf("const I* operator & \n");
return &m;
}
};
void main()
{
O v;
const O::I* p = &v;
}
Output:
const I* operator &
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: This does not compile.
What man you are not passing the reference to pointer rather you passing the pointer that is why it is not compiling
Maxwell Chen wrote:
class I { } m;
const I* operator &()
{
printf("const I* operator & \n");
return &m;
}
I guess what will be your implementation for the typecast operator from the above code
public:
class I { } m;
operator const I* &()
{
printf("const I* operator & \n");
return &m;
}
here you are not returning the reference you are returning the pointer, if you modify it as
class I { }
const *m;
operator const I* &()
{ printf("const I* typecast operator & \n");
return m;
}
it will compile
Maxwell Chen wrote: This compiles, but the member operator function is not invoked.
This i agree
|
|
|
|
|
Rajkumar_R wrote: class I { } const *m;
operator const I* &() {
printf("const I* typecast operator & \n");
return m;
}
My modification below.
class O
{
public:
class I
{} const* m;
O() : m(new I()) {}
operator const I* &() {
printf("operator const I* & \n");
return m;
}
};
void main()
{
O v;
const O::I* &p = v;
const O::I* &q = (const O::I* & )v;
}
Maxwell Chen
|
|
|
|
|
So now you can compile without error
|
|
|
|
|
Rajkumar_R wrote: So now you can compile without error
Yes!
Maxwell Chen
|
|
|
|
|
Hi Experts,
I want to add my command at the right click of file and folder. So I have to make some changes in registry entry. Could anyone tell what steps to follow?
I do not have any idea of shell menu.
Regards.
Pther
|
|
|
|
|
pther wrote: I do not have any idea of shell menu.
Then doing a search for tutorials on shell extensions would be a good idea...
Look under desktop development, shell and ie programming, beginners for a good start.
(I'm not being unhelpful - everything I know about shell extensions came from Michael Dunn)
Iain.
|
|
|
|
|
Hello Friends,
I need to do some checking when user clicks turnoff windows.
I am trying to capture windows shutdown event in my Win32 Console Applicaton.
In MFC application WM_ENDSESSION work well upto some extent but Win32 Application doesn't provide that message handler.
Please give some suggestions.
Waiting for the reply
abhi
|
|
|
|
|
SetWindowsHookEx to hook WM_ENDSESSION or WM_QUERYENDSESSION ?
Maxwell Chen
|
|
|
|
|
But SetwindowHook creates problem in terms of performance and extra load of dll will be there.
Is there any other way.
abhi
|
|
|
|
|
AbhijitAkude wrote: Win32 Application doesn't provide that message handler
What do you mean by that?
The message is handled like any other window message.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Create a hidden window and handle the WM_ENDSESSION message.
Steve
|
|
|
|
|
Hi all,
I've a problem in ListView management. The problem is the following:
when the ListView looses the focus, the currently selected item in the
ListView looses the selection: the selection in the ListView is not mantained
switching from a control to another in the user interface.
How can I solve this problem ? I'd like to let the ListView to mantain
the selection.
Thanks a lot !
|
|
|
|
|
Have a look in the styles. I'm pretty sure there's one called "show selection always".
Just peeked... LVS_SHOWSELALWAYS exists.
Iain.
|
|
|
|
|
|
Hi all,
I have to make a library to convert the Color from Lab value to RGB value. However, I have no much idea on the calculations or algorithms.
Suppose I will receive a data (Char pointer) then convert to RGB.
Can some of you give me some hints or examples? Please Please...
I believed that this should be easy for some experts.
Thanks for your help..
|
|
|
|
|
azusakt wrote: I have no much idea on the calculations or algorithms.
You don't have much idea or you have absolutely no idea? Tell us what you've tried.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Actually, I'm a beginner in writting Graphic related program. especially in C++.
I have no idea on the calculation for processing & converting the LAB to RGB. So I hope to find some examples with codings that I can easily to learn and understand .
Could you provide me some program examples if you have this experience.
Thanks a lot.
modified on Tuesday, January 29, 2008 10:04:23 PM
|
|
|
|
|
azusakt wrote: I have to make a library to convert the Color from Lab value to RGB value. However, I have no much idea on the calculations or algorithms.
But documentation exists http://en.wikipedia.org/wiki/Lab_color_space#Advantages_of_Lab[^].
There is also the very nice Guillaume Leparmentier's article [^] here at CP .
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.
[my articles]
|
|
|
|