![]() |
|
#1
|
|||
|
|||
problem understanding how to use templateshi,
i'm trying to use the CMap template, instantiating it like this: CMap<char,char*,CString,CString*> map; should these classes parameterising it be ok? i get an error from somewhere in the cmap code: error C2664: 'SetAt' : cannot convert parameter 1 from 'char' to 'char *' thanks. |
|
#2
|
||||
|
||||
|
Quote:
I think I would have done it more like this CPP / C++ / C Code:
or, better yet: CPP / C++ / C Code:
You can do some reading here Template-based classes and here CMap Class. If you would have posted your call to SetAt, I could have told you where exactly the problem is... Oh, well, I think it's more challenging to find it on your own (and you'll problably learn a lot more) Best regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
|
ah but i havent called setAt yet..
thanks for the help though. this is going to make me sound very stupid now, but how is char & different to char * ? is the second one is a pointer and the first one is a reference? whats the difference? |
|
#4
|
||||
|
||||
|
Quote:
Well, think of using functions. There is a distinctive difference on how you would use variables passed as pointers compared to those passed using references: CPP / C++ / C Code:
They are both passed by address, but inside the functions they are treated different. (Observe the *) So, inside this template, methods like SetAt will be called, but they won't know how to deal with your data, sice they expect a reference type. But did my previous post fix your problem? Regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#5
|
|||
|
|||
|
yeah that explains it, the problem is fixed now.
thanks again. |
|
#6
|
|||
|
|||
Re: problem understanding how to use templatesHi,
i'm trying to use CMap but i get some strange problems whit it. I have defined my variable as follows: CMap <CString,LPCTSTR,CUser*,CUser*> m_umUsers;I have my class CUser well done and I have a function called AddNewUser defined as follows: void CVerificadorDoc::AddNewUser(CUser* pUser)I call this function when I push a button in my dialog, the execution shows the messageBox correctly before the SetAt function but is there where nothing else happens. It never cames back to the calling function. I can not understand why, there isn't any error showed. Is there anyone capable to explain me what to do or what is happening? thank you very much in advance |
Recent GIDBlog
More photos on Flickr by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CD burner will not burn, new problem | sdshaman | Computer Hardware Forum | 4 | 06-Feb-2008 23:17 |
| Tee chart problem | Arun | C++ Forum | 0 | 01-Sep-2004 23:23 |
| Another FX 5600 problem (but with details that might shed light on this) | BobDaDuck | Computer Hardware Forum | 2 | 16-Apr-2004 07:53 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The