|
Thanks fefe.wyx,
Question answered.
regards,
George
|
|
|
|
|
George_George wrote: Is it legal and good code to call one constructor from another in the same class?
Currently no, but the next version of the Standard includes delegating constructors[^] which will enable you to get such functionality, although with a slightly different syntax.
|
|
|
|
|
Thanks Nemanja,
I assume in current version of C++ and for common vendors/compilers, like MSVC 2008/2005, it is not supported, right?
regards,
George
|
|
|
|
|
George_George wrote: I assume in current version of C++ and for common vendors/compilers, like MSVC 2008/2005, it is not supported, right?
Right. I bet it would show up in gcc first. Keep an eye on Status of Experimental C++0x Support in GCC 4.3[^]
|
|
|
|
|
Thanks Nemanja,
Question answered.
regards,
George
|
|
|
|
|
VC++ : In Wizard mode property sheet in Windows NT it is not showing the "close"button in the title bar
|
|
|
|
|
You check whether you are passing the parameters correctly when creating property sheet.
It will be helpful if you post code snippet..
Incase close button not available in NT, try adding a button in propertysheet for closing purpose.
Best Regards,
Suman
|
|
|
|
|
in the .h file
CImageList m_iml
CComboBoxEx m_ctlCity;
in the .cpp file
DDX_Control();
BOOL CMyDlg::OnInitDialog()
{
m_iml.Create(16, 16, IDL_COLOR32, 2, 1);
m_iml.Add(theApp.LoadIcon(IDI_ICON1));
m_iml.Add(theApp.LoadIcon(IDI_ICON2));
m_ctlCity.SetImageList(&m_iml); //1.set the image list
COMBOBOXEXITEM cbi = {0};
cbi.mask = //with pszText and image
cbi.iItem = -1;
cbi.iImage = 0;
cbi.pszText = _T("Paris");
m_ctlCity.InsertItem(&cbi);//2. insert items
cbi.iImage = 1;
cbi.pszText = _T("London");
m_ctlCity.InsertItem(&cbi);
m_ctlCity.SetCurSel(0);
}
But run the app, Neither string nor image in the CComboBoxEx control, what do i miss?
|
|
|
|
|
See if this works:
cbi.iItem = 0; // for the first item
m_ctlCity.InsertItem(&cbi);
...
cbi.iItem = 1; // for the second item
m_ctlCity.InsertItem(&cbi);
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
change cbi.iItem = -1; to cbi.iItem = iIndex;
The code doesn't work either;
BTW, I see in emule's source code, it always uses cbi.iItem = -1 to InsertItem(&cbi);
modified on Monday, March 24, 2008 2:17 AM
|
|
|
|
|
fantasy1215 wrote: But run the app, Neither string nor image in the CComboBoxEx control, what do i miss?
Try getting the text part working first before working with images.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
here: a^x=b, how to know x? where a and b are known but x.
I found that,b=a^x=(~a&x)|(a&~x)
and how to do next?
Thanks
|
|
|
|
|
|
thanks.
I have found the solution is: b = a^x ==> x = a^b;
Regards.
|
|
|
|
|
Yeah, that works.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
one of my classmates told me that,i forgot that many years,lol
in "Discrete Mathematics"
|
|
|
|
|
Hello everyone,
From MSDN virtual base class reference, what means "If a derived class overrides a virtual function that it inherits from a virtual base class, and if a constructor or a destructor for the derived base class calls that function using a pointer to the virtual base class, the compiler may introduce additional hidden "vtordisp" fields into the classes with virtual bases."
I do not understand why an additional hidden filed is needed?
http://msdn2.microsoft.com/en-us/library/wcz57btd.aspx#Mtps_DropDownFilterText
thanks in advance,
George
|
|
|
|
|
George_George wrote: http://msdn2.microsoft.com/en-us/library/wcz57btd.aspx#Mtps_DropDownFilterText
The circumstance requiring such field it is explained here http://msdn2.microsoft.com/en-us/library/7sf3txa8(VS.71).aspx[^](however I have to admit I don't fully understand the whole machanism ).
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
|
|
|
|
|
Thanks for sharing this, CPallini!
I also do not understand this, quoted below. It is appreciated if you or other gurus could share points about what does the following paragraph mean?
http://msdn2.microsoft.com/en-us/library/7sf3txa8.aspx[^]
--------------------
The problem is that the virtual function may be passed an incorrect this pointer as a result of discrepancies between the displacements to the virtual bases of a class and the displacements to its derived classes. The solution provides a single construction displacement adjustment, called a vtordisp field, for each virtual base of a class.
--------------------
regards,
George
|
|
|
|
|
Well I think we can understand the quoted paragraph keeping in mind the memory layout drawings of the OP article. Probably whenever the memory layout is optimizied to retain only a copy of the base class stuff, you need that offset field to keep aligned, in derived classes, info about the base one (roughly speaking, the compiler says:"OK you ask to me two identical copies of the base stuff, I'll make only a single one and all will go fine if I provide you an additional field, i.e. the offset to adjust derived class pointers alignement to such single copy").
BTW it's only a guess, actually I'm not a guru and this time the matter is a bit intricate.
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
|
|
|
|
|
Thanks CPallini,
I do not quite understand what do you mean "you need that offset field to keep aligned"? Why and what needs to be aligned? Could you provide more description or some pseudo code please?
regards,
George
|
|
|
|
|
Do you remember the memory layout depicted in your OP article? That was only a schematic, neverthless it showed that mamory layout changes (with respect to ordinary derivation) whenever base class stuff is reported only once (instead of twice) in the derived one. Hence the need of an offset to rearrange things. As I stated before, it is only a guess (based on my arrogant assumptions... ).
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
|
|
|
|
|
Thanks CPallini,
Re-arrange for what purpose? To facilitate what operations? Why if not re-arranged, it will not work for what operation?
CPallini wrote: the need of an offset to rearrange things
regards,
George
|
|
|
|
|
Somethimes an example is better than a thousand of words:
class A
{
int a;
public:
A(){a=0;}
virtual int do_things(int a){this->a = a; return 0;}
};
class AB: public A
{
int ab;
public:
AB(){ab=1;}
virtual int do_things(int a){A::do_things(a);this->ab = a+1; return 1;}
};
class AC: public A
{
int ac;
public:
AC(){ac=2;}
virtual int do_things(int a){A::do_things(a);this->ac = a+2; return 2;}
};
class ABAC: public AB, public AC
{
int abac;
public:
ABAC(){abac = 4;}
virtual int do_things(int a){AB::do_things(a);AC::do_things(a);this->abac = a+4; return 4;}
};
int main()
{
ABAC abac;
}
If you put a breakpoint at the end of main function and put abcd inside the watch window, then you'll see something like the following
- abac {abac=4 } ABAC
- AB {ab=1 } AB
- A {a=0 } A
- __vfptr 0x0041574c const ABAC::`vftable'{for `AB'} *
[0] 0x00411136 ABAC::do_things(int) *
a 0 int
ab 1 int
- AC {ac=2 } AC
- A {a=0 } A
- __vfptr 0x00415740 const ABAC::`vftable'{for `AC'} *
[0] 0x0041111d [thunk]:ABAC::do_things`adjustor{12}' (int) *
a 0 int
ac 2 int
abac 4 int
Line [0] 0x0041111d [thunk]:ABAC::do_things`adjustor{12}' (int) * shows the adjustor, i.e. the offset (equalt to 12 decimal, 0xC hex) needed to align vftable'{for `AC'} to ::`vftable'{for `AB'} (0x00415740 + 0x0000000c = 0x0041574c).
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
|
|
|
|
|
Thanks CPallini,
Your sample looks great! I have debugged it by myself.
Two more questions about your sample,
1.
CPallini wrote: __vfptr 0x0041574c const ABAC::`vftable'{for `AB'} *
This line means the address of __vfptr pointer is 0x0041574c? Or the value of __vfptr pointer is 0x0041574c?
2.
CPallini wrote: [0] 0x00411136 ABAC::do_things(int) *
This line means the address of __vfptr[0] pointer is 0x00411136? Or the value of __vfptr[0] is 0x00411136?
regards,
George
|
|
|
|