|
well.. thank you for this.. but my real problem is as follows..
i mostly use containers of classes.. and so i am writing functions to compare them (i hardly ever use stuff like greater)
and how do i achieve this..
my fun's look mostly like:
bool rmore (const Class* &l, const Class* &r)
{
return (l->x > r->x);
}
i wanted to write sthing like
bool rlikestring (const Class* &c, string s)
{
return (c_membervar = s);
}
does this work this way? (it would be pretty cool for algorithms like remove_if)
thanks for your answer
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
sorry.. it should be
bool rlikestring (const Class* &c, string s)
{
return (c.c_membervar == s);
}
but since i am using const, the compiler would've announced it anways
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
Well, if I've understood your need, you must write a functor (sometimes called function object) to plug into find_if and similar arguments. It'd go like this:
class rlike
{
public:
rlike(const string& s):s(s){}
bool operator(const Class* &c){return c.membervar==s;}
private:
const string& s;
} Now you can use this functor as follows:
find_if(L.begin(),L.end(),rlike("hello dude")); Look for function objects on the net for further info on this kind of constructs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I want to know details about writing an import for .DXF files
for a CAD software used in the Laser Construction business. I
have the file formats of the .DXF file but not the CAD software.
I think I need that format. Please be kind to give information
about how to tackle this problem. What other information do
I really need? This has to be done in C++/VC++.
|
|
|
|
|
Let me see if I understand what you're asking for: You want details of the file format for some CAD software, but you don't tell us which software?
I think you'll find more help at wwww.psychic.com.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Not knowing the CAD software envolved, you may find a reference to the file format at:
http://www.wotsit.org/
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
Please step to the rear of the car and make room for more victims. - John Simmons the Outlaw programmer, 1st Feb 2002, in the lounge
|
|
|
|
|
Hi !
I'm about to write a little app which will be a RPN Calculator, in order to learn a little bit of C++ and MFCs.
The calculator, as all RPN Calc, will have a stack, and at each position of the stack could be a value. The type of this value could be an integer, a float, or anything I might think of (complex number,...).
I thought that I should have an abstract class (CValue), and derive from this class many specific classes for each possible type. Thus, the stack will just store CValue objects, but, when displaying them, the appropriate method will be called. (I hope a make myself clear !!!)
My question now is : if I want to add two values, but, for example, one is of type CFloat and the other one is CInteger (but both are derived from CValue), how can I do it ? How can I make sure that in this example, the CInteger will be converted to a CFloat, and the result will be a CFloat ? Same problem would occur when, for example, multiplying a CComplex with a CInteger ? How can I make it work, in a good object-oriented way ?
Any help or hint will ne greatly appreciated !
Thanks !
Jerome
|
|
|
|
|
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
|
|
|
|