|
Thanks! I knew it was something simple, I just couldn't find the method.
|
|
|
|
|
class A {};
class B { public: B (A a) {} };
int main()
{
A a;
B b=a;// this statement gives no error! How? please explain
}
|
|
|
|
|
Sakthi_Vel wrote: B b=a;// this statement gives no error! How? please explain
Because this statement calls the constructor directly, it's equivalent to...
B b(a);
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http:\\nibuthomas.wordpress.com
|
|
|
|
|
Sakthi_Vel wrote: B b=a;// this statement gives no error! How? please explain
Have you set a breakpoint in B 's constructor?
"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
|
|
|
|
|
|
I just want to know how may i be able to get the source of a generated page inside Microsoft WebBrowser?
I just cant find a way to get the source of the generated page once the page has finished downloaded.
Thank you very much
-Ruperts-
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
I haven't used any of the VC++ 2008 betas, but the addition of multi-threaded compilation and improved debugging for multi-threaded programs has me interested. I currently use Visual Studio 2005 Standard (with SP1 and Intellisense hotfix), but am considering downloading the free VC++ 2008 Express, and then just copying all the files/folders from the VC\bin folder to the VC 2005 program folder.
I'm also having problems with the Document Explorer from VS2005 crashing consistently on XP x64 SP2, so am also downloading the VS2008 MSDN beta, hoping this will fix my problems.
For completeness, I'll also probably download the latest Platform SDK (as I'm still using the VS2005 one).
Has anyone else tried this ?
Is VC++ 2008 suitable for production code ?
Is it as easy as I make out ?
|
|
|
|
|
In what circumstances dynamic_cast is used?
|
|
|
|
|
Here[^] is a nice article that discuss about that.
|
|
|
|
|
|
I have a small doubt on edit box. i am making a dialog based application. i have three edit boxes in the screen.
1.want to know how to set a range(eg 1-10) if i enter 11 it should pop a message.
2.i want to set the final value of the first edit box as the minimum value of the third edit box and the final value of the second edit box as the final value of the third edit box.
hope the query is understood.
|
|
|
|
|
to restrict an edit to a given range, you could attach it a spin control.
for the second point, where are you stuck ? getting/setting an editbox value ? or the calculation behind that ?
|
|
|
|
|
extremely sorry for again putting the query in the forum.. well i wanted to know how to set the third edit box value.
|
|
|
|
|
Chandrasekharanp wrote: extremely sorry for again putting the query in the forum..
no problem mate
Chandrasekharanp wrote: well i wanted to know how to set the third edit box value
like this for instance:
CEdit* pEdit = (CEdit)GetDlgItem(IDC_MY_EDIT);
pEdit->SetWindowText(_T("Hello World"));
|
|
|
|
|
this i am aware..
take for example.
my first edit box minimum range is "1" and maximum range is "10". and the second edit box the mininum range is "1" and the maximum range is "20". i want "10" to be the minumum range of the third edit box and 20 to be the maximum range of the third edit box.
hope its clear.
|
|
|
|
|
In this case, I would make a function validating every editbox content. And if all are ok, then return true.
If you have lot of EditBoxes (I have one dialog with 24 coloured comboboxes), you can make it dinamically. I put the example to NUM_EDITS different editboxes.
CEdit* m_aPEdits [NUM_EDITS];
.
void CMyEdit::OnInitDialog ()
{
m_aPEDits [0] = (CEdit*) GetDlgItem(IDC_MY_EDIT1);
m_aPEDits [1] = (CEdit*) GetDlgItem(IDC_MY_EDIT2);
m_aPEDits [2] = (CEdit*) GetDlgItem(IDC_MY_EDIT3);
m_aPEDits [3] = (CEdit*) GetDlgItem(IDC_MY_EDIT4);
}
BOOL CMyEdit::ValidateEditContents ()
{
int nError = 0;
for (int i = 0; i < NUM_EDITS; i++)
{ int nTemp = -1;
nTemp = itoa (m_aPEdits[i]->GetDialogText ());
if ( ((10 * i) < nTemp) && (nTemp < (10 * (i+1))) )
continue;
nError++;
}
if (!nError)
return TRUE;
return FALSE;
}
void CMyEdit::OnOK ()
{
if (ValidateEditContents ())
m_bDlgOK = TRUE;
}
void SomeClass::A_Function ()
{
CMyDialog newDlg;
EditStartLabel:
if (IDCANCEL == newDlg.DoModal ())
goto EditEndLabel;
if (!newDlg.m_bDlgOK)
{ MessageBox ("One of the edits has an invalid value, please correct it", "Error", MB_OK);
goto EditStartLabel;
}
EditEndLabel:
return;
}
I know that is not an elegant code, but it works perfectly. I won't probably use this structure in my next project or if i rewrite this one in the future, so any tip, correction, opinion... will be wellcome.
But to start getting the concept about data validation in a "simple" way I think is good
Hope it helps
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Goto/Labels !!! your code belongs to the Coding Horror forum !
|
|
|
|
|
I know , it was my first MFC programm but the final project of studies, my teacher was "Dr." in java and wanted a particular structure very easy to read, he changes my structure at the third month . So I started to ask him what he wanted before coding new things.
Why do you think I am going to rewrite my whole programm?
It has some code horrors (like this) that I want to erase and I want to add language support, "standard" windows functions like undo, copy, paste... and port some things to DLLs.
But the doubt was about validation and functionality and this aspect is quite clear
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
you could start by changing your code to using while/for loops, because goto/labels don't bring anything useful here. actually, the only point they could be useful is to get out of several nested loops, for performance purpose... i don't see that in you code
|
|
|
|
|
I still have lot to learn, thanks for the advice I had thought use the do... while (!m_bDlgOk)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
toxcct wrote: to restrict an edit to a given range, you could attach it a spin control.
That would not keep the user from typing 11 into the control.
"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
|
|
|
|
|
yeah, i figured that out after i posted...
|
|
|
|
|
in MFC you can use:
DDV_MinMaxInt(pDX, IDC_EDIT_BOX, 1, 10);
in the function DoDataExchange of your dialog...
|
|
|
|
|
Haroon Sarwar wrote: DDV_MinMaxInt(pDX, IDC_EDIT_BOX, 1, 10);
This is a bad idea as it falsely gives the user the impression that everything is fine until they decide to click the OK button. Then they get some sort of error message. It's better to disable the OK button until all controls contain valid data.
"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
|
|
|
|
|
thanks for the piece of code.. now i have another doubt.. can i use this piece of code multiple times in the DoDataExchange Function..
something like this,
<br />
DDX_Control(pDX, IDC_EDIT1, m_edit1);<br />
DDX_Text(pDX, IDC_EDIT2, m_edit2);<br />
DDX_Text(pDX, IDC_EDIT3, m_edit3);<br />
DDV_MinMaxInt(pDX, IDC_EDIT1, 1, 10);<br />
DDV_MinMaxInt(pDX, IDC_EDIT2, 1, 20);<br />
DDV_MinMaxInt(pDX, IDC_EDIT3, 20, 30); <br />
|
|
|
|