|
To clarify, if I set an iterator like:
vector::iterator ite = myvec.begin() + 4;
Will ite, my iterator, remain valid as long as the vector variable is not modified?
Yes, provided you don't insert or delete anything from myvec from the moment you set the value of ite .
With std::list s, on the other hand, iterators remain valid no matter if you insert or delete elements (except if you delete the element the iterator is pointing to, of course.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for confirming that for me.
I Dream of Absolute Zero
|
|
|
|
|
Hello All,
I am getting assertion failed message while runing my application in Win32 debugIU mode:
error message is like this:
Assertion failed
Program: .....\x.exe
file oledisp2.cpp
line: 321
As we know it is vc++ src file. And my application is running properly in Win32 cmrelIU mode. But problem in Win 32 debugIU mode. And that too, same application is running on other PC properly.
What could be the reason? Would you please provide some solution?
Regards,
Jokhan
|
|
|
|
|
Step in through the code and isolate the line shouting Assert.
There is no spoon.
mail
|
|
|
|
|
Have you looked at line 321 of oledisp2.cpp? An unknown type is being used in a call to InvokeHelperV() .
jokhan wrote:
And my application is running properly in Win32 cmrelIU mode. But problem in Win 32 debugIU mode...What could be the reason?
Because the ASSERT() macro will catch program errors only when you are using the debug version of MFC. It will be turned off (and produce no code) when you build your program with the release version of the library.
Don't let the fact that when no errors/messages are produced during the release version of your product that your product is indeed error-free. Whatever condition exists that caused the assertion to fire in the debug version still exists in the release version.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I would like to seek some advice as in general terms how proceed with my current program, written as a MFC Dialog (C++) application in Visual Studio .Net.
I have developed it over the last few months as an application which creates its own internal database – a large array of a user defined structure. I can access this data by two means; by name or index (0 to n).
Now I need to provide an interface to this array (database) so that I can write other applications to use this database along side my program.
So my question is
‘What sort of interface should I provide?
and
How to implement it? i.e. do I need to protect the data during access etc
I have never written any DLLs, just used them, also currently think of using the database item name as the access key and would like the option to write these programs in C or C++, so I question the use of CString as the database names are held in a CStringArray .
Any comments greatly appreciated.
|
|
|
|
|
IMHO a better approach with a long term view will be to make ur internal database external on some Database servers(M$SQL/MySql,Oracle). Sorry for not answering wot you exactly asked.
There is no spoon.
mail
|
|
|
|
|
Hello Friends,
I want to use the cursor control keys (Key up, key down, key left, key right) and the cursor should move according to the appropriate item which is being displayed in the listview. The Item should be get selected with respective to the cursor key.
please help me regarding the above matter.
Thank you in Advance only,
Neelesh J Jain.
|
|
|
|
|
use OnKeyDown or OnKeyUp
You can read up about these functions on MSDN.
hope this helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I am using onKeyUp member function only, but how to navigate in the list box according to the appropriate key.
Thank you,
Neelesh Jain.
|
|
|
|
|
test for VK_UP (VK_DOWN)
then you can set the selectitem (or SetCurSel) property or something of the listbox +1 or -1.
Look up the members for CListBox...
Good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Neelesh K J Jain wrote:
...in the list box...
In your original post, you indicated this was a listview, yet now you indicate it is a listbox. Which is it?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello all,
needing to allocate a large number of buffers (let's say 20.000 buffers of
sizes between 8 and 200 bytes (I do not know their size at first)), which method would you recommend:
1. malloc (slow from my tests)
2. dlmalloc (Doug Lea's malloc replacement)
3. other
If your solution is a custom memory allocator, I need it to work on Win32
(e.g. Win9x included). I've done tests with dlmalloc and it seems pretty
fast. Perhaps an experience/advice of using it in the real-world would help.
Thanks.
Regards,
George Ionescu.
|
|
|
|
|
http://www.mathtools.net/C_C__/Memory_management/index.html[^]
Short of rolling your own with Virtual*() i was impressed with what i read about Hoard.
If you know the allocation size extents(8-200) and the pattern of allocations you should be able to write an optimized allocator that will outperform most generic implimentations.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Since you are using VC++, the choice should be the new operator.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
How to eliminate this warning?
warning C4652: compiler option 'Generate Browser Info' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header.
pls help
Mithuna
|
|
|
|
|
I suggest you completely clean and rebuild your project. This should eliminate the warning.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
|
Hi,
I am developing a client server application with vc++.
I have the following 3 main classes
* PayrollDlg - This is the main dialog box
* WageDlg - This dialog box is accessible thru PayrollDlg
* AbsSocket - This class manages the networking aspect i.e creating a socket & sending , receiving data.
Now i need to create an object os AbsSocket that can be accessed from both PayrollDlg as well as WageDlg. Where do i declare this object to achieve this. If i declare the AbsSocket object in either PayrollDlg or WageDlg classes it becomes local to that class. What i actually want to know is where is the main() function as if i declare the AbsSocket object in this main it can be accessed anywhere right?
|
|
|
|
|
You can declare it as global in one cpp file and then declare it using extern in another
AbsSocket g_AbsSocket;
extern AbsSocket g_AbsSocket;
or if u want a cleaner way you can do this
class CGlobalVariables
{
static AbsSocket g_AbsSocket;
};
CGlobalVariables::AbsSocket g_AbsSocket;
and include this class in stdafx.h
then u can use it like
CGlobalVariables::g_AbsSocket
whereever u like
as for accessing the main function, in MFC it is buried deep under the classes of MFC u can't(shouldn't) access it
hope it helps
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
You could always derive PayrollDlg and WageDlg from a common class where AbsSocket is a member variable.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Using visual C++ 6.0, I have created a user drawn bitmap button and the up,down,focused,etc states and it works just fine. It's a red sphere, but I would like to be able to change it to blue,green,yellow,etc.
I've tried
m_pic1.AutoLoad(IDC_GREEN,this);
where GREEN is the "GREENU" sphere picture, but it just crashes during run time.
I think I may be really barking up the wrong tree.
B
|
|
|
|
|
I think I would use an imagelist.
Load all bmp's in there and switch accordingly.
hope this helps.
(eg. for setting an icon to a button I did this:
icon = (HICON)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_PRINT), IMAGE_ICON, 16, 15, LR_DEFAULTCOLOR);<br />
pPrintbutton->SetIcon(icon);<br />
I presume it's round about the same for a bmp)
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
--------------------Configuration: xt3 - Win32 Debug--------------------
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpmtd.lib(delop.obj)
xt3.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
xt3.exe - 2 error(s), 0 warning(s)
What causes this? And what should I do to fix it easily.
Thanks very much.
|
|
|
|
|