|
Thanks, obvious it's no my cup of tee.
btw, i have another book <high permance="" web="" site=""> that was publiched by O'lley, is extreme good.
But i need a full view of designing and publicizing of a web site.
Thanks, though.
|
|
|
|
|
BTW does your previous problem solve?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
if you are referring the Heap Management problem yes
if "CRT runtime error, must terminate the application" then no, alas.
|
|
|
|
|
JackPuppy wrote: C# and ASP.net
And so you asked in the C++/MFC message board. Good move, Einstein. Why didn't you try the correct one[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi, I have problems whith the BOOST <unordered_map> container.
GetMessageFunctorHashMap() returns an unordered_map<string,Functor*>.
Then I try to insert a new item. The operation seems to be OK but when I request if the container is empty i allways recieve TRUE.
Can anyone helps me, please?
GetMessageFunctorHashMap()["Hello"]=(Functor*) new SpecificVoidFunctor<messagesystem>(this, &MessageSystem::Exit);</messagesystem>
GetMessageFunctorHashMap().empty(); returns 1
Thanks!
|
|
|
|
|
If the result type of GetMessageFunctorHashMap is unordered_map<string,Functor*> , then your first line of code modifies a COPY of your unordered_map ...which is then discarded, because it goes out of scope.
To modify the unordered_map that GetMessageFunctorHashMap references, the return type needs to be a reference to unordered_map<string,Functor*> , i.e. unordered_map<string,Functor*>&
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You are right! Thanks!
Now the code crashes in the string library when internally the Unordered_Map container tries to compare two strings. Anyone knows if unordered_map can compare and hash strings by default? Or i have to define the hash function and the compare function?
Thanks!
|
|
|
|
|
It won't hash the strings - you use hash_map for that (although in my experience, std::map has better performance).
But it will compare strings properly - I guess it'll use operator< ?
BTW - this code worked fine on g++ 4.0.1 (using Boost's TR1 implementation) and on VS2008 (using its own TR1):
#include <string>
#include <iostream>
#include <unordered_map>
int _tmain(int argc, _TCHAR* argv[])
{
std::tr1::unordered_map<std::string, int> a;
a.insert(std::make_pair("Hello", 10));
a.insert(std::make_pair("Goodbye", 20));
std::cout << a.count("test") << std::endl;
std::cout << a.count("Hello") << std::endl;
return 0;
}
This does comparisons...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks!
Finally I used a simple std::map<string,>, works OK and it's fine for the first version of my system. But I still don't known why the unordered_map and the hash_map containers don't works....Well....that remain a mystery xD.
|
|
|
|
|
I have 20 names and there makes stored in a map. My requirement is to get hghest marks of top 10 studens.
please let me know the sorting algorithim to find that out.
Thanks in Advance
|
|
|
|
|
find out how value_compare(), it will compare the values that way you will know which key comes first
|
|
|
|
|
|
You may try to implement yourself a simple sorting algorithm, like, for instance [^], it maybe an interesting experience.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you used this:
std::map<MarkType, NameType> marksAndStudents;
(where MarkType is the type you use for a students marks and NameType is the type you use for a students name, then *rbegin() points at the student with the highest mark - try this:
std::map<int, std::string> s;
s.insert(std::make_pair(10, "10"));
s.insert(std::make_pair(20, "20"));
s.insert(std::make_pair(30, "30"));
s.insert(std::make_pair(40, "40"));
s.insert(std::make_pair(50, "50"));
s.insert(std::make_pair(60, "60"));
s.insert(std::make_pair(70, "70"));
s.insert(std::make_pair(80, "80"));
s.insert(std::make_pair(90, "90"));
s.insert(std::make_pair(100, "100"));
s.insert(std::make_pair(110, "110"));
s.insert(std::make_pair(120, "120"));
std::map<int, std::string>::const_reverse_iterator it = s.rbegin();
for (int i=0;i<10;++i)
{
std::cout << it->second << std::endl;++it;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi
I wrote a code that has multiple threads, each thread has to run independent of another and complete at different times. I tried using the sleep() function to delay execution for some seconds but the program terminates while threads are still sleeping. I also tried using usleep() function, its works fine with small parameters but behave the same as sleep() with large parameters.
Is there anyway that I can delay program termination until my threads are awake and have completed there task?
OR
Is there a better way of delaying the threads other than using sleep() and usleep()?
Thanx
|
|
|
|
|
Call pthread_join() [^] for each thread you have created before your main program exits.
|
|
|
|
|
thanx,
I do pthread_join() call for all my threads but the sleeping ones do not get there. From the sample file, I have to create about five thread, only two are required to delay. The delayed threads do not get to the pthread_join() call but the other three get there. Seems the programs continues running as if there are no sleeping threads.
|
|
|
|
|
Hi All,
I have .Prn file which was generated out of PCL printer.I need to find a string in that file and then I have to replace it with another string.
Iam able to do it by using stream writer,streamreader,Binary reader,binary writer and file streams.
But if gave a print(LPR)for it, it get failed and giving me syntax error as Illegal tag.
If I print original file it is printing very well.
I came to know that while writing it has lost some of its originality ,so it was failed
Please help me
Thanks in advance
|
|
|
|
|
It sounds like you've done more than just changing the string. I don't know about the format, but maybe just before the string is a tag describing the string and its length?
Try replacing just one character in the string - or maybe make one already there be in upper instead of lower case.
Yours experimentally,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi,
Thanks for the reply,
The original file size is like 16k, after the editing it becoming as 22k..
more over it is not normal file,It is a file generated by PCL printer.
So may be during the conversion it is losing printer supported font.
so that's the reason printer cannot understand the file(after editing)to print.so it gives syntax error as Kernel and Illegal tag error.
I have no clues to overcome this problem
kindly help me
|
|
|
|
|
If the size is changing from 16k to 22k, you're doing a lot more than swapping a string!
Just try with baby steps. Tweak one little bit, test, tweak a bigger bit, test, and so on.
I've no idea about the format either - this is just general advice.
It's worth jumping in the deep end sometimes, but other times you just dip one toe in the water.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi all
I am having a C++ class and in that some functions are also there.One variable i want to use in a function only.So i can declare it inside that function or as a member variable.
Variables declared in a function will be saved on the stack but what about member variables.
Which way should be more efficient.
Can anybody help me to show some good articles in good programming practices.
Thanks and regards
Deepu
|
|
|
|
|
Where member variables are stored will depend upon how the class is instantiated.
If an object of the class is created on the stack, the member variables will also reside on the stack.
If the object is created on the heap, the member variables will also reside on the heap.
If a variable is used only within a function, you should declare it within that function itself.
And if you want the value retained across function calls, then declare it static.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Hai !
There is a global byte pointer in my apllication, I donot know its size,
is there any inbuilt function in MFC to know its length similiar to GetLength () for strings !!
thanks!
|
|
|
|