|
How is it that you don't rely on a simple "Find in Files" <devstudiodir>\include ?
And I swallow a small raisin.
|
|
|
|
|
Thanks, StephaneRodriguez
Let me try. But when do things like this,
some other questions may arise. So ...
Cheers,
George
|
|
|
|
|
If you're in VC++ .NET you can right-click, "Go to Definition".
This usually saves a search on include files.
Concussus surgo.
When struck I rise.
|
|
|
|
|
On VC++ .Net, you've got an even simpler way to discover the type, just put your mouse on it and you'll get the tooltip!
And I swallow a small raisin.
|
|
|
|
|
Thanks for your advice Daniel pal!
I am using Visual Studio 6.0.
Cheers,
George
|
|
|
|
|
I want to store strings in an array.How do I do it in ATL?
|
|
|
|
|
std::vector<std::string> will work for any C++ based program. For a more ATL-flavored solution, CSimpleArray<CString> would do, but unless you're using VC7 you'll need to link MFC in order to get CString . To get rid of this dependency you can use CComBSTR instead (which are not exactly regular strings), or some of the many CString clones available on the net.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
but unless you're using VC7 you'll need to link MFC in order to get CString
You can use WTL to get CString.
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
what about IEnumString?
nous sommes les maitres
nous sommes les esclaves
nous sommes partout
nous sommes nul part
nous maitrisons les lettres noires
|
|
|
|
|
This is my program:
#include "deque"
class CMsg
{
int MsgID;
}
main()
{
deque<cmsg*> que;
CMsg * pMsg=new(CMsg);
que.pushfront(pMsg);
}
and I compile it with gcc.
The error is:deque<cmsg *,..="">::pushfront(CMsg *&) no matching function.
So can anybody tell me why?
|
|
|
|
|
try using push_front instead.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
yeeeeeeep. It works! Thank u guys! Thank u very much.
|
|
|
|
|
I think the problem is that you don´t specify what element type will be stored in the deque, you must fix the declaration:
deque que;
specifying the deque element type:
deque<cmsg *=""> que;
Don´t forget that STL stands for Standard Template Library! , so "deque" is a class template, not a simple class.
"nobody knows it, but you´ve got a secret smile, and you use it only for me"
|
|
|
|
|
he actually does have the type declared, the HTML viewer simply chewed up the angle brackets, here is what he had:
deque<CMsg*> que;
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks, I forgot the HTML nature of this message board...
"nobody knows it, but you´ve got a secret smile, and you use it only for me"
|
|
|
|
|
You should use <>to include stuff that is from the std library, or anything else coming from your include paths and not your own project. That is not causing your problem, but it's what you should do in general.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Hi,
I need to keep an (arbitrary) order for a map<string, thingy="">. My idea is to use the map<> for fast lookup, and a separate list<string> to keep the original order, but I wonder if there's a better way.
TIA
Peter
One day I might find it quite amusing how touching tongues make life so confusing Anne Clark again [sighist]
|
|
|
|
|
What are you storing as the value in your map?
Could you create a class for your value that contains your data and a sort value?
class MyData
{
MyClass m_MyClass;
int m_SortIndex;
};
What do you need to determine from the separate list? Do you need to traverse the data in a sorted order once you find a starting point or something? It really depends on what you're going to do after you find an item in your map.
Todd Smith
|
|
|
|
|
value is either a string, or a class mainly containing a string-string map (with the same problem):
I need fast string-based lookup, so I guess I will need a map.
(lookup is case insensitive, but original case should be preserved, a linear search in an unsorted list is probably a really bad idea)
I will continually insert, erase, and change values in the map, but at the same time, I need to iterate over the map in the same order as items were added to the map (bare thiose that were removed, of course)
e.g.
map["polonius"] = "rat"
map["ophelia"] = "dead";
map["hamlet"] = "mad";
// iterate over map so I get it in order polonius, ophelia, hamlet
map["hamlet"] = "dead";
map["polonius"] = "dead";
map.erase("ophelia");
// iterate original order again - now only polonius, hamlet
map["ophelia"] = "floating";
// iterate - now it doesn't matter if it's p-h-o, or p-o-h
if the key was an integer, I wouldn't hesitate to simply use a separate list as an index, but I wonder if there's a mroe effective method
e.g.: could I use a list< map::iterator >, or even a list <map::value_type *=""> instead? (provided I remove them from the lsit before removing them from the map) Although other iterators should not be affected by inserting / removing, I'm still a bit "shaky" on this topic...
Peter
One day I might find it quite amusing how touching tongues make life so confusing Anne Clark again [sighist]
|
|
|
|
|
peterchen wrote:
a linear search in an unsorted list is probably a really bad idea
How many items do you expect the container to hold? And what kind of performance do you need? A list would be easiest to implement assuming a linear search isn't to slow.
Todd Smith
|
|
|
|
|
typical 10, 100 not unusual - admitted, that's not too much.
but typical access is over two maps, and comparison is case-insensitive (which adds up)
But maybe you're right, I should implement it with a simple list, and see how fast it is.
One day I might find it quite amusing how touching tongues make life so confusing Anne Clark again [sighist]
|
|
|
|
|
Why does the lookup need to be based on string comparison? If you just want fast lookup preserving the order of insertion, try using this class as the key of your map this:
class seq_string
{
public:
seq_string(const char *str):str(str),count(total_count++){}
seq_string(const std::string& str):str(str),count(total_count++){}
seq_string(const seq_string& r):str(str),count(total_count++){}
operator const char *()const{return str.c_str();}
operator const std::string&()const{return str;}
bool operator <(const seq_string& r)const{return count<r.count;}
private:
std::string str;
unsigned int count;
static unsigned int total_count;
};
...
unsigned int seq_string::total_count=0;
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks for the suggestion, but I need both string-based lookup, and iteration in (temporal) order of insertion (although your class keeps the info, it would about O(n*n) to actually iterate in "sorted by count" order)
I'll go with the list<> implementation and a linear search, and make some speed comparisons.
[edit]
some interesting results (not all to much surprising)
times only for lookup
with <= 10 strings, the list is faster, for 25 strings it's list is about factor 2 slower, factor 3 for 50. (map looses early for creation of a std::string from literal when doing the lookup, and additional comparison for equality)
Having said that, With 25 strings in a list I get ca. 200.000 accesses / second on my 1.3GHz box, not astonishing, but fast enough for most uses.
All this is just lookup, map insertion is of course much slower due to additional comparisons (and I might be stuck with thousands of inserts and just a few lookups), so list implementation is "perfect enough"
One day I might find it quite amusing how touching tongues make life so confusing Anne Clark again [sighist]
|
|
|
|
|
Hi all,
I will write a ATL server exe programm with outgoing event interface and connection points for some client programs. For this solution I haven't found any good samples, so my first implementation is not working
My event interface is derived from IUnknown and
only a interface. In the client I use the normal
Advice methode to make the sink interface working, but I cannot see any events.
The second problem, I must fire some events from a worker thread in a third party Dll or using a timer. Here I have a error
! fire event failed (0x8001010e).
Is here a simpler solution than using
CoMarshalInterThreadInterfaceInStream and a worker thread ?
I hope some COM Guru has a answer
|
|
|
|
|
I am getting an error in the cout statement??
What should I do??
C:\My Documents\lakshmi\cplusplus\stldeque\test.cpp(28) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::deque<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char>
main() {
string alpha[4] = {"nava", "dana", "lakshmi", "pavi"};
deque<string> ids1;
for (int i =0; i<4; i++) {
ids1.push_back(alpha[i]);
}
typedef deque<string>::iterator id_iter1;
for (id_iter1 i1 = ids1.begin(); i1 != ids1.end(); i1++ )
cout << *i1 << "\n";
}
|
|
|
|