|
You should overload the == operator and use the find algorithm.
<br />
class cObj<br />
{<br />
int objNum;<br />
string objName;<br />
Below,you can actually have the int type as well that you can check for your "2" directly than passing it from an object. But in case you want to change the search condition sometime later, this doesnt help. Better pass the object and get the member from it.
<br />
bool operator == (const cObjSent)
{ <br />
return ((objNum==cObjSent.objNum));<br />
}<br />
}<br />
<br />
void main()<br />
{<br />
list <cObj> cObjObject;<br />
list <cObj> ::iterator cObj_iter;<br />
<br />
cObj_iter = find(cObjObject.begin(), cObjObject.end(), YOUR_COBJ_SEARCHOBJECT_HERE [Like for eg:your obj2]
);<br />
<br />
}<br />
<br />
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
thanks a lot Marc!
May The Force Be With You...
|
|
|
|
|
Hi all i want to make progress bar inside list control(report style). I have found various articles regarding this but they don't fulfil my requirements.
i have made a sdi application and that sdi window is divided with a vertical splitter controls in two parts.Each veiw is derived from CFormVeiw and have a list control in it.I want to make progress bar in my list control and that progress bar should start when i click a button on toolbar.
How to do this.....
Thanks in advance
|
|
|
|
|
There are very good examples regarding this on codeproject i dont remember exact names but try something XListControl you will get it.
|
|
|
|
|
|
Hi,
I want to write a program that when I input integer then the output will have commas if it has more than three digits. For example,
-2007 and 2000000 would be printed as -2,007 and 2,000,000 respectively..
# include <iostream>
# include <iomanip>
using namespace std;
int main ()
{
double digit;
cout <<" print it with comma "<< endl;
cin >> digit;
cout <<setiosflags(ios::fixed| ios::showpoint)<< setprecision(3) <<endl;
cout <<digit <<endl;
return 0;
}
dalmar mahamoud
|
|
|
|
|
This really sounds like a homework problem. It is not that difficult to do.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi all. Is it possible to have a program that executes under a different name under Windows? For example, program.exe executes under newprogramname.exe? Only reason why i asked is because i've always wandered how installation programs do it. Thanx in advance!
|
|
|
|
|
I don't think it's possible. If it was, it would be a heck of a security vulnerability - unless the full path was placed somewhere, it would screw up every piece of anti-virus software in the world.
Install programs execute under the same name, as far as I know. It's just that they sometimes create temporary apps and run them as children.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
I don't think it is possible, and could be suspicious...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Yes!
I do not know what ‘Ninja-the-Nerd’ was talking about, but you can change the name all you want. What that has to do with installation I have no clue – so obviously I have no idea what you are talking about.
If you do not believe me – pick a program and rename it through the explorer and then run it.
The only problem that might occur is if that program was specified as the one used to handle a particular file format. If you change its name – then the system will not know what program to use (now), unless you tell it what the new name is.
Well actually – depending on the program – there could be other problems (rarely) if other programs depend on that one (a.k.a. file type handling). But let’s not go there or we will all end up with a head ache .
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I read that as "can I have an EXE called whatever and displaying as something else in the taskmanager?".
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
hey guys,
I've got a little problem...
I have two classes. One is the member of the other. but the other still needs a pointer to the first.
<br />
#include "B.h"<br />
class A;<br />
class A<br />
{<br />
public:<br />
B m_BClass;<br />
};<br />
<br />
#include "A.h"<br />
class B;<br />
class B<br />
{<br />
public:<br />
A* m_pAClass;
};<br />
somehow this doesn't work...
He gives me:
"Error 4 Error C2143: Syntaxerror: missing ';' before '*'"
cause he doesn't know the class A. Though I forward declarated it.
A friend of mine told me about an "inclusion deadlock". but I cannot figure out how to solve it.
i need to to a global class with all necessary includes.
any hints or links?
thx in advance
PS: should I put the forward deklaration before the "#include" ???
|
|
|
|
|
your problem is you got to forward declare class A is the class B header...this is the only way class B will know about class A, but when using a pointer in class B for class A, you do not have to forward declare, because you are already including the header files for class A inside class B!!!
try taking about the forward declare in both file, I both your files should compile... note in class A you have an auto member to class B object, in this case a forward declare would not be sufficient and you would need to include the header file of class B in the header file of class A.
most of you include should be done in your source file(.cpp) not your header files, unless you like long builds....man there is just too much to talk about this topic and I don't want to get you lost...LOL
Yours Truly, The One and Only!
|
|
|
|
|
yes I tried that, too. but when I want to edit other members of A in B:
<br />
void B::Edit()<br />
{<br />
m_pAClass->somemember = somevalue;<br />
}<br />
I get, of course, somemember is unknown identifier... ???
|
|
|
|
|
Hello,
<br />
#include "B.h"<br />
class A<br />
{<br />
public:<br />
B m_BClass;<br />
<br />
void SayHelloToMyLittleFriend() {}<br />
};<br />
<br />
class A;<br />
class B<br />
{<br />
public:<br />
A* m_pAClass;
<br />
void LetsRock();<br />
};<br />
<br />
#include "B.h"<br />
#include "A.h"<br />
<br />
void B::LetsRock()<br />
{<br />
<br />
m_pAClass->SayHelloToMyLittleFriend();<br />
}<br />
|
|
|
|
|
nice work mate!
Yours Truly, The One and Only!
|
|
|
|
|
what if I do not have an implementation file (cpp) because I wanna keep the code in the header? does it work, too? Or do I have to ship everything into an implementation file?
|
|
|
|
|
that should not matter if you put everything into a header file, but in most cases you will want to separate declaration with implementation! .... people just want to see the class members and know how to call it, they don't care how it's implemented and having to read tons of line of code figure out all your methods in a class is not the way to code.
if you want to declare everything inside the head file you have to make all the method inline, otherwise you're going to get linking errors.
i.e
class A {
public:
void MyFunc() {
}
};
void A::MyFunc() {
}
I am sure you will figure it out
Yours Truly, The One and Only!
|
|
|
|
|
i have tried to draw image on non client area(glass effect) in windows vista aero glass view with GDI+ in MFC (included alpha channel) as suggested in one of previous article. but image gets invisible there because when i write the same code in xp it draws the image in non client area. what could be the reason for it?
|
|
|
|
|
Hi,
Windows explorer uses soem icons(bitmaps) for folder, New Folder, Delete etc. Are those standard icons? Can we use same icons in my application? If yes what are the ID's of those icon? Can I load them using LoadResource(), or LoadBitmap() function?
Regards,
Hemant
|
|
|
|
|
some programs like "irfanview" can load icons of apps.
simply drag the app into irfan view and you get the icon.
search your windows and windows\system folder for *.dll they should be contained in some
|
|
|
|
|
The shell32.dll is one of them, I believe. This contains a lot of major ones, although others are in other places.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
Alot of similar icons/bitmaps are included with Visual Studio.
You can also open any exe or dll in visual studio and copy resources right to your projects.
Whether it's legal to use them or not, I'd say it's not legal without permission. At the same
time, Microsoft wants us to have consistent user interfaces
I'm not a lawyer...you're on your own there.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The older MSDN documentation for UuidCreate() lists some return values that indicate the global uniqueness of the id depending on the presence of an ethernet/token ring address.
RPC_S_OK
RPC_S_UUID_LOCAL_ONLY
RPC_S_UUID_NO_ADDRESS
However, the newer MSDN documentation throws in a statement...
"For security reasons, UuidCreate was modified so that it no longer uses a machine's MAC address to generate UUIDs"
Does this mean that UuidCreate() function will now always return RPC_S_OK ?
|
|
|
|