|
Actually, the page you linked containened a unworkin solution, but I browsed that thread, and found a really working one.
I was very close to the correct solution, so to derive the std::greater<...> from the compare func, just I did it reverse.
Anyway really a 'big' thanks you for the help.
|
|
|
|
|
Hi,
I have the same problem in a project.
As I am a beginner, Could you write your solution; please ?
thank you for you help.
|
|
|
|
|
Yes, of course.
The solution is quite simple, almost trivial, but only if you think "with a microsofter's head".
So the secret is that you, instead of deriving your sorter class from the std::greater<...>, have to derive the std::greater<cyourclass> from your CYourSorterClass, which actually doesn't exists.
to be clear:
so just extend std with the following lines:
<br />
namespace std<br />
{<br />
template<> struct greater<CYourClass*> : public binary_function<CYourClass*, CYourClass*, bool><br />
{<br />
bool operator()(const CYourClass*& x, const CYourClass*& y) const<br />
{<br />
return x->sortbyvalue < y->sortbyvalue;<br />
return x < y;<br />
}<br />
};<br />
}<br />
then sort your list just the same way as it was a 'int' etc...:
<br />
nodes.sort( std::greater<CYourClass*> ( ) );<br />
that's it. I hope I could help.
|
|
|
|
|
|
Newbie question I am afraid.
I want to share a number of common utility classes across multiple projects. These common classes are NOT stable and are still under development.
From the documentation I have read, I am supposed to use the component gallery.
I have created a 'utility' project to hold the source code of my common classes. From this project I can add classes into the gallery.
When I use the add mechanism to include 'common' components from the gallery, the 'common' class is included into the target project.
However a copy of the source files are included into the target project and subsequent changes to the source common class are not reflected in the target project.
Can anybody give me direction on this?
|
|
|
|
|
1- Put all your classes in a directory
2- Add the directory where the clases are in Tools/Options/Directories
3- When you need a class only add the fields in your project.
4- when you include the header make it into tags....
<br />
#include <yourheader><br />
Carlos Antollini
Do you know piFive[^] ?
|
|
|
|
|
Create a 'utility' dll and include it in your project. Mark each exported class like the following:
class AFX_EXT_CLASS MyUtilClass{
}
I use a little script in the prebuild instructions of projects that use common classes that copies the header files and dll/lib into the project.
Hope that at least gets you started. I think there are some alternative articles on the site as well as the previous post.
ed
Regulation is the substitution of error for chance.
|
|
|
|
|
i would like my program to start when a user logs (i use Win2K), but that would be too easy to put a link on the start menu. what is the way to access the windows registry, to write or read inside, and finally, how may i proceed to insert a program in the registry start list.
is there anyone to help please?
TOXCCT
|
|
|
|
|
toxcct wrote:
i would like my program to start when a user logs (i use Win2K), but that would be too easy to put a link on the start menu.
Are you saying that you do not want such a link?
toxcct wrote:
what is the way to access the windows registry
With the registry API, such as RegOpenKeyEx() , RegQueryValueEx() . Also check out the CRegKey class.
toxcct wrote:
how may i proceed to insert a program in the registry start list.
Check out this article.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
excuse my english, i don't find the right words everytime i would like
i said i didn't want to insert a shortcut to my program on the start menu. Instead, i prefered it to launch when the registry reads its list (there may exist a list of the programs that start when windows start, isn't it?
TOXCCT
|
|
|
|
|
hkey_local_machine/software/microsoft/windows/currentversion/run
"there is no spoon" biz stuff about me
|
|
|
|
|
toxcct wrote:
there may exist a list of the programs that start when windows start, isn't it?
Yes, consult the link I provided.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hello all
I'm programmatically adding and removing icons to windows systray. Icons showup correctly when I'm adding it programmatically but when I remove it programmitically the icon still shows up until I put the mouse pointer there. Is there any way to refresh the system tray so that the icons showup properly.
many thanks for your help.
Hari.
|
|
|
|
|
Hello,
How are you removing the window - I have seen this problem before if you miss:
Shell_NotifyIcon(NIM_DELETE, IconNotificationData);
Without the above the notification gets sent when you put the mouse over the icon - making it vanish.
Regards,
Simon
|
|
|
|
|
Hi Simon
Thank you very much for reply.
|
|
|
|
|
In using the operator= in a subclass, how do I call the parent classes operator=? It's been a while since I've done any C++!
<code>
class CPerson{
CPerson& operator =(const CPerson& other);
}
class ATypeOfPerson : public CPerson{
CPerson& operator =(const CPerson& other);
}
ATypeOfPerson & ATypeOfPerson ::operator=(const ATypeOfPerson & other)
{
if(this != &other)
{
}
return *this;
}
</code>
Thanks!!
ed
|
|
|
|
|
that's quite simple.
you can create a pointer or a reference to the base class. Then, that variable will point to/reference not only the base class objects, but also the subclasses objects. for example :
CBaseClass {
<font style="color:blue;">int</font> m_iField;
<font style="color:blue;">public</font>:
CBaseClass();
~CBaseClass();
CBaseClass <font style="color:blue;">operator</font>=(CBaseClass& ref);
};
CSubClass : CBaseClass {
<font style="color:blue;">public</font>:
CSubClass();
~CSubClass();
CSubClass& <font style="color:blue;">operator</font>=(CSubClass& ref);
};
<font style="color:blue;">void</font> main (<font style="color:blue;">void</font>) {
CSubClass CSObj1, CSObj2;
CBaseClass& refCBObj = CSObj1; <font style="color:green;">
refCBOb2 = CSObj2; <font style="color:green;">
}</font>
if you would a function of the SubClass with the Same name in the both classes to be used instead of the BaseClass, you must define the BaseClass function as virtual :
CBaseClass {
<font style="color:blue;">public</font>:
CBaseClass();
<font style="color:blue;">virtual</font> ~CBaseClass(); <font style="color:green;">
CBaseClass <font style="color:blue;">operator</font>=(CBaseClass& ref);
};
TOXCCT
|
|
|
|
|
class CPerson{
CPerson& operator =(const CPerson& other);
}
class ATypeOfPerson : public CPerson{
ATypeOfPerson & operator =(const ATypeOfPerson & other);
}
ATypeOfPerson & ATypeOfPerson ::operator=(const ATypeOfPerson & other)
{
CPerson::operator=( other );
return *this;
}
|
|
|
|
|
Whoa.. CP says the time difference between our posts are 15 minutes. But I swear I didn't take 15 minutes to write my post! Are posts delayed?
--
<british-accent>Pass the jam, would you?
|
|
|
|
|
Good question. That's really strange. <insert twilight="" zone="" theme="" song="" here="">
|
|
|
|
|
And to both of you ...thanks
One more question..
How about inside operator== when it is declared a friend function?
Thanks again!
ed
|
|
|
|
|
I usually divide operator== into two cases:
1) bool operator==(const ClassType&)
2 a) bool operator==(const OtherType&, const ClassType&)
2 b) bool operator==(const ClassType&, const OtherType&)
If I only have 1), I keep it as a member of the class. But if I have either 2 a) and/or 2 b), which I always make friend functions since I want symmetry (only 2b can be a member), I also make 1) a friend function for full symmetry.
It really doesn't matter, unless you make them virtual and want to override the behaviour of the operators. But I don't see a good case where that would be appropriate - especially since you can never virtualize 2 a). A 67% fool proof design is not a good design IMO.
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
when a funtion is declared as friend into a class, it is used like a member function...
So, what i told you in my precedent post is applyable.
use your BOOL operator== (const CBaseClass&) like you would do with a member function (heard that it as been declared friend
TOXCCT
|
|
|
|
|
Jörgen Sigvardsson wrote:
Are posts delayed?
Not always. We have to stop yours at the border, though, in order to let Homeland Security search them for contraband. We regret the inconvenience...
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
Ahm. What is homeland security doing in Canada? Wouldn't that be foreignland security, or almost-homeland security, or american-apart-from-the-frenchies-land security?
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|