|
i usually do it like that, and never made use of reserve(), so i think your statement is false
|
|
|
|
|
webHamlet wrote: ...you can always use the reserve() function to allocate upfront.
What does using reserve() have to do with the subject? Using reserve() is performance-related.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
toxcct wrote: a good example to test that is by creating a std::vector<std::string>. strings can have different sizes, but the vector still works, doesn't it ?
Actually a std::string is always the same size. It's the memory it manages that can vary in size. For example, it may use new to allocate a memory block and store a pointer to it in the std::string : the pointer is always the same size.
Steve
|
|
|
|
|
No problem really. But it looks a little weird to push CStrings into a vector. Did you consider using a std::string instead? or if you are so concerned about using MFC, did you have a look at CStringArray?, my personal option would be vector-std::string though.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
prithaa wrote: I just wanted to know what happens if a vector is stored with objects of different sizes.
i have used vector of vector in many of my application.. i havn't faced any problem doing so!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi all.
I have project and I need installator, sow I use Setup Wizard and add it to my project, but I dont know what hapend, it installs somting else not my project, it installs dialog window API without any control.
there isnot controls thet I add to this dialog [buttons, Icon, Editbox ,Listbox . . . ].
if you can help me.
|
|
|
|
|
david bagaturia wrote: if you can help me.
*Silently walks away*
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Mind if I tag along?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Mark Salsbery wrote: Mind if I tag along?
Sure you can. You intend to help someone and end up reading some post like that. Pain.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Yes. Sometimes it's best to walk away
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
|
I would like to know if there is a way to set the start cursor position in a RichEdit control when the RichEdit control is first loaded.
For example, if the text string inside the RichEdit control is "Hello World", is there any way to set the starting cursor position in the RichEdit control to be just before the 'W' character?
|
|
|
|
|
what about using CRichEditCtrl::SetSel() ?
|
|
|
|
|
hi all, can you please give some info about implementing the CapCreateWindow() function for capturing image from the webcam..
|
|
|
|
|
I'm pretty sure I answered yesterday, but do you mean capCreateCaptureWindow?
If so, THE info can be found here: Video for Windows[^]
Particularly, the "Video Capture" section.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Which Win32 API cmd.exe usage for Clipboard operations.
Regards
Rakesh
|
|
|
|
|
Clipboard functions.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i made this small prog:
<br />
#include <iostream><br />
using namespace std;<br />
int c;<br />
<br />
int main() {<br />
<br />
cout << "Enter number from 1-3:" << endl;<br />
<br />
if (c = 1) {<br />
cout << "Hey!" << endl;<br />
} <br />
if (c = 2) {<br />
cout << "Hmm!" << endl;<br />
}<br />
if (c = 3) {<br />
cout << "What!" << endl;<br />
} <br />
}<br />
<br />
But whenever i open it, it closes at same time, any ideas why it is like that?
|
|
|
|
|
In addition, all of your tests need to be comparisons instead of assignments:
if (c == 1)
It's also a good idea to always initialize your variables:
int c = 0;
Hope that helps
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
reyyy wrote:
if (c <code>=</code> 1) {
cout << "Hey!" << endl;
}
if (c <code>=</code> 2) {
cout << "Hmm!" << endl;
}
if (c <code>=</code> 3) {
cout << "What!" << endl;
}
Three words, dude... Warning Level 4 !
Those are assignments, not equality tests.
BTW - the app is closing quickly because it is running to completion. Make it wait for input or something in order to keep it running.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
How do i assign cin to this code for user input?
|
|
|
|
|
reyyy wrote: if (c = 1) {
Had you put the constants on the left of the operator, you would have quickly spotted the error.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
reyyy wrote: How do i assign cin to this code for user input?
in short, you should go back to your homeworks/lessons.
in long :
#include <iostream>
#include <conio.h>
void main() {
int c = 0;
std::cout << "Enter number from 1-3:" << endl;
std::cin >> c;
if (c == 1) {
std::cout << "Hey!" << endl;
}
else if (c == 2) {
std::cout << "Hmm!" << endl;
}
else if (c == 3) {
std::cout << "What!" << endl;
}
else {
std::count << "unknown value typed !" << endl;
}
getch();
}
ps: don't worry about my std:: , i just don't like the using namespace std
ps2: avoid global variables (see that i declare c inside the main function.
ps3: if you declare a function of type int , it should return a value (otherwise, declare it void - what i did here)
ps4: don't write successive if like you do, because the compiler will have to do every tests even if one is already succeeding. prefer using the else if statement for this.
-- modified at 12:27 Tuesday 27th February, 2007
can someone explain me what's wrong with this post to get rated like it is ?
|
|
|
|
|
std:: is the same as using namespace std; , right? and why did you use void main() instead of int main() ?
|
|
|
|
|
reyyy wrote: std:: is the same as using namespace std; , right
not quite. when you write an identifier, the compiler searches is it the namespaces imported, and in the global namespace. but using too many namespaces at the same time can issue into name ambiguities. so as writing the whole identifier name is not so hard to do, i prefer letting the things clear for the compiler AND for the readers of my code...
reyyy wrote: and why did you use void main() instead of int main() ?
this answer is in my previous reply. as you have no return statement in your main, you ave then no need to return a value, thus the void .
|
|
|
|