|
If the salary calculation is the only thing that's different between employees and contractors then I suggest you try something like the following
class contr_salary_calc
{
public:
int operator()( employee& E )
{
}
};
class perm_salary_calc
{
public:
int operator()( employee& E )
{
}
};
class employee
{
public:
employee()
{
m_bPermanent = false;
}
void calculate()
{
if( m_bPermanent )
{
m_PermCalc()(*this);
}
else
{
m_ContrCalc()(*this);
}
}
void MakePermanent()
{
m_bPermanent = true;
}
private:
bool m_bPermanent
contr_salary_calc m_ContrCalc;
perm_salary_calc m_PermCalc;
};
Somtimes there's nothing wrong with a little if..else logic when the word is little less static than your class hierarchy.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Thanks for the suggestion.
Is there a way to call the sibiling function???
and r there any sites/books for case studies for designing classes?
|
|
|
|
|
|
How can I subclass or create a popupmenu in another application?
I use a WH_CBT Hook to be informed when a special window is created. Now I'd like to add popupmenus to all
of the application's buttons or alter existent popupmenus.
Any ideas?
|
|
|
|
|
Hi, so here's my problem:
Basically I want to format a CString such that the trailing zeroes are all eliminated.
For example, let's say I have a double such as: 610.15100000
And I want to print this to a CString so that I can set the text in an edit control.
Right now I do something like this:
CString strTemp;<br />
double fVal = 610.151;<br />
strTemp.Format(TEXT("%lf%), fVal);
But in the edit control, it shows up with all the zeroes at the end:
610.15100000000
How do I make it print so that it shaves off the extra zeroes at the end?
Thanks!
KR
|
|
|
|
|
KellyR wrote: How do I make it print so that it shaves off the extra zeroes at the end?
Assuming you want three places after the decimal, use:
strTemp.Format(TEXT("%.3f"), fVal); If, however, you are wanting to remove all trailing zeros regardless of how many, see the TrimRight() method.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
modified on Friday, April 18, 2008 11:58 AM
|
|
|
|
|
The above will fail on fVal = 1.051000 (provided I understood his requirements).
[added]
Actually it fails also on his input (610.15100000 ).
[/added]
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
|
|
|
|
|
CPallini wrote: The above will fail on fVal = 1.051000
How so? strTemp has a value of 1.
CPallini wrote: Actually it fails also on his input (610.15100000).
It worked fine for me. strTemp has a value of 610.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: It worked fine for me. strTemp has a value of 610.
But it needs to be 610.151. Thanks though!
KR
|
|
|
|
|
So use .3 instead of .0 then.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think he wants to remove trailing zeroes in a general way, i.e. that his input was just an example.
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
|
|
|
|
|
CPallini wrote: I think he wants to remove trailing zeroes...
Yeah, I read it wrong. I thought he wanted to remove everything after the decimal. Sorry for the confusion.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You may use strTmp.TrimRight(_T("0")); to the purpose.
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
|
|
|
|
|
strTmp.TrimRight(_T("0")); works as long as I have numbers after the decimal, but if I don't, it leaves me with whole numbers that end with a decimal, i.e:
610.00000
would become: 610.
However, strTmp.TrimRight(_T(".0")); seems to work! Thank you much!
KR
|
|
|
|
|
Please tell me how to use the functions present in a DLL file in a new WIN32 console application.
I want to use a function from an existing DLL file, in a new program.
Thanks.
|
|
|
|
|
|
On Visual Studio, usually you have to:
(1) include the library header file
(2) add the library .lib file to you project.
(3) make the IDE know about the folder path of your library .lib file.
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
|
|
|
|
|
There is a dialog and it has more than one controls.I want to get all these controls to set or change some their properties at runtime. To do this , i use that code.
<br />
CWnd* pChildWnd = wnd->GetWindow(GW_CHILD);<br />
<br />
while ( pChildWnd )<br />
{<br />
pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);<br />
} <br />
But i can't get controls and this while loop enters infinite loop. Please help me to get all controls. Thanks.
|
|
|
|
|
mehmetned wrote: There is a dialog and it has more than one controls.I want to get all these controls...
Can't you use EnumChildWindows() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
It was very useful for my problem. thanks
|
|
|
|
|
Its good news for me it was helpful for you.
|
|
|
|
|
Hamid. wrote: Its good news for me it was helpful for you.
Hows life going dude... evrything ok at your END
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi Experts,
I have written a shell context menu COM dll. It is working fine on all files and folders. But this is not coming on briefcase. How can I achieve that.
|
|
|
|
|
I would suspect that the briefcase is not a real directory, but a namespace extension (like the recycle bin). In which case, you might be out of luck.
For this sort of thing, I use regmon from sysinternals. Navigate to the "directory", start regmon going, and see what COM reads explorer does when you right click on a briefcase item. It may not even look at the keys you have your extension registered under, which would be a hint to give up, or look if any of the keys it *does* look at give you any ideas.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|