|
You could write a conversion operator for the different types. The conversion operator can upgrade certain types to the next level when it is necessary. For example, you would create this function for your CInteger class:
<br />
CInteger::operator CFloat()<br />
{<br />
return CFloat(this);<br />
}<br />
This will convert a CInteger object to a CFloat object whenever the compiler sees the opportunity to do this. For example, given this function:
<br />
bool CFloat::Add(CFloat lhs, CFloat rhs);<br />
call the function with these parameters:
<br />
CInteger i;<br />
CFloat f;<br />
<br />
CFloat answer;<br />
<br />
answer.Add(f, i);<br />
<br />
i, or CInteger would transparently be converted to a CFloat for you. The only hard part to this solution is to determine the proper relationships between all of the objects and what parameter types should be converted or upgraded to the other types.
|
|
|
|
|
personall i see two chances for you:
* one would be to make a function (e.g. operator +,- and so on...) that converts all different numbers to the same type (e.g. double so you could add them pretty simple)
* another way would be a chance to make overloaded functions:
add (double r, int l) but i don't think this would be pretty sh*tty
just my thoughts.. i think there is a better approach.. but in the moment i don't know any..
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
Hi Jerome, your problem is a classic in OOP, and has been thouroughly studied. The usual technique to deal with it is called double dispatch. Do a search on Internet for this term, lots of papers and code snippets will show (some even featuring number hierarchies similar to what you are planning to build).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
when we make a link with "https://",the IE browser will pop up a dialog to let us
select a personal certificate.
my question is:
At this time,how can I have the browser read my certificate from the special directory on my disk!
|
|
|
|
|
wabc wrote:
when we make a link with "https://",the IE browser will pop up a dialog ...
No it doesn't.
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
https:// means that web page is encryped or something, so that your visit to it and data transfer is supposed to be secured. The online banking sites I used all begin with https://. But most of the time, they don't ask for any certificate. Sometimes it will prompt that "You are going to view a secure web site, while some of the stuff are not secured. Do you want to view the unsecure stuff too?".
Good luck!
|
|
|
|
|
I wonder how to make an installation package for projects developed using VC++ 6. Are there any tools that come along the Visual studio or have to do something in the codes?
DJ
|
|
|
|
|
It's part of installation of visual studio6.
Installshield for visual C++6.
Disk1 of visual studio6
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
Thanks Mazy, I got it and installed InstalShield.
DJ
|
|
|
|
|
What I am going to do is to record the system bootup and shutdown time for Windows 2000/NT, we may use either VB or VC++ for programming.
Any idea? Appreciate you help.
DJ
|
|
|
|
|
while (buffersize != 16386)
{
read = sock.read(data, 2048);
int appenLen = (read+buffersize) > 16386 ? : (16386-buffersize) : read;
memcpy(bigbuff+buffersize, data, appenLen);
buffersize += appenLen;
}
|
|
|
|
|
Thanks wangyiming.
But how about I want a program to be run at the time of system startup and shutdown?
DJ
|
|
|
|
|
Sorry the pre answer is other
------------------------------
you can write application:
run : gettime, then write thetime into windows register ( subKey: bootuptime )
exit : gettime, then write thetime into windows register ( subKey: shutdowntime )
|
|
|
|
|
Thanks. But I am not sure whether there are any fields in the Windows registry that record the on/off time, or I have to write something into the windows registry?
DJ
|
|
|
|
|
put the exe into windows statup menu
|
|
|
|
|
|
You can quickly get the system up time by calling GetTickCount() , however, this has the caveat that the time is stored in a four-byte integer. Consequently, the time rolls over after 49 days and change. I know that Windows 2k has a performance monitor that provides this, but I haven't taken the time to look up how to access it.
Jon Sagara
What about ?
|
|
|
|
|
C:\My Documents\DataStru\main.cpp(147) : fatal error C1004: unexpected end of file found
can anyone tell me how to fix this ?
please
|
|
|
|
|
check for all { and }
All of them should have equal numbers
Mazy
|
|
|
|
|
Did you include the stdafx.h header file in main.cpp?
|
|
|
|
|
You might have to change your project settings so that you're not using precompiled headers for main.cpp. If you want to use precompiled headers, then make sure you have included stdafx.h (as previously mentioned).
Jon Sagara
What about ?
|
|
|
|
|
I'm having a logic problem or something but i'm just not seeing it
I am relaying data using an 16k buffer, but the data gets corrupted. Here is an oversimplified example of whatI'm doing:
*pseudocode*
buffersize = 0;
while(other condition)
while (buffersize != 16386)
{
read = 0;
read = sock.read(data, 2046);
memcpy(bigbuff+buffersize, data, 2046);
buffersize += read;
}
memcpy(data, bigbuff, 2046);
buffersize-=2046;
memmove(bigbuff, bigbuff+2046, buffersize);
}
that pretty much covers it, thanks for your help.
<b>S</b>tephen <b>C</b>aldwell
Blackfission, CEO
http://blackfission.myip.org:81
|
|
|
|
|
16386 isn't a multiple of 2046. buffersize is probably getting larger than what you can handle. Change that to while (buffersize <16386)
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
while (buffersize != 16386)
{
read = sock.read(data, 2048);
int appenLen = (read+buffersize) > 16386 ? : (16386-buffersize) : read;
memcpy(bigbuff+buffersize, data, appenLen);
buffersize += appenLen;
}
|
|
|
|
|
Kinda helped a little.
Stephen Caldwell
Blackfission, CEO
http://blackfission.myip.org:81
|
|
|
|