Archived

This topic is now archived and is closed to further replies.

story about mfc

This topic is 5114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all, today I tried to use the CStringList class. after several minutes I saw that It is a part of mfc. and if I want to use it I must include afxcoll.h instead of windows.h. I think it has some replacements for windows.h definitions. but after I tried to compile my application and I got an error message saying timeGetTime function is not declared. I included mmsystem.h for it and this time it compiled with no errors. But now I get the linker error message: "birdofprey error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in libcmtd.lib(delete2.obj)" and many like this one. my question what does cause this and how do I fix it? is there any other string list class that can be used instead? I''m not familiar to mfc I like to write my own code for game programming but this stringlist class will make me lose time with a boring code writing. best begards serdar

Share this post


Link to post
Share on other sites
I know nothing of CString Class.

But if what you are looking for is just handling strings use std::string, just include < string >

[edited by - pjcast on December 12, 2003 3:31:59 PM]

Share this post


Link to post
Share on other sites
If you do not currently know MFC, you will very likely never need to know MFC ... as microsoft doesn''t even intend to ever release any more updates to it ... it is a completely end-of-line technology now.

I agree with the above poster that what you want is probably std::string which is part of the standard C++ library.

I highly recommend that you be made aware of the following elements of the C++ standard library (at your leisure, as needed):

std::string
std::vector, std::list, std::deque
std::map
std::stack, std::queue

I recommend you learn the basics of string and deque first, and then map ... cause with those 3 you can do a whole lot of usefull work.

WHEN it comes time to look for outside libraries to use with your C++ program ... there are many choice instead of MFC ... you could use boost, QT, Borland''s VCL, Microsoft''s .NET, SDL, DirectX, OpenGL, many many things (some do many things, some do just one really well ... some you can mix and match, others don''t play nice together ... but none is worse than MFC).

Share this post


Link to post
Share on other sites
I was typing during your reply ...

here is a string list:

std::list< std::string > myList;

here is another string container (different performance characteristics, similar interface / usage):

std::deque< std::string > myList;

the 3 basic list containers "vector" "list" and "deque" all use the exact same function names and prototypes for the elements they support (but they support some different things ... list list does NOT support random access (like arrays do)).

the "map" and "set" container classes are noticably different, but very usefull for other things you want to acomplish (and also "multiset" and "multimap") ...

I have used every one of those classes many times, except "multiset" which I''ve never used, and "multimap" which I''ve only used twice.

I use one or more of the 3 lists in every usefull app ... and usually the map as well ... they are just the core of building nearly any powerfull behavior.

Look for books on The C++ Standard Library, or the C++ Standard Template Library (STL) ... including ONLINE REFERENCES

Share this post


Link to post
Share on other sites
ok I''m trying to use std::string instead of CString. But someone please can tell me how do I use it with strdup, strcspn,... I mean string manipulation routines like this? I can''t use it as the char* parameter. howw can I convert it? the ms help isn''t enough.

thanks

serdar

Share this post


Link to post
Share on other sites
CoderTCD, there are function to manipulate the string class without those funcs, I dont recall them specifically offhand, but to do what you ask is simple:

std::string s = "this is a test";

s.c_str(); // returns const char* = "this is a test"

oh and for better helps, try doing searches on google for C++ STL, or standard template library

[edited by - duke on December 12, 2003 9:23:33 PM]

Share this post


Link to post
Share on other sites