Using STL and MFC at the same time.

Started by
16 comments, last by mikef 21 years, 8 months ago
I was wondering if it is possible to use MFC and STL at the same time and if so are there any benefits of doing so. Also, would you guys recomend learning the win32 api before learning MFC? [edited by - mikef on August 14, 2002 2:18:24 PM]
Advertisement
Sure, there''s no problem with that. I use maps of CString key, CString value all the time. CString provides a lot of handy functions for strings that I don''t have to write, and the STL provides an excellent storage mechanism.

MFC offers its own collection classes (CObArray, CStringList, etc.) but they are not nearly as powerful, flexible, and useful as an STL container.
Thats good, I learning how to program, I used Practical C++ by QUE as a start, I now have STL Tutorial and Reference Guide, Second Edition, an Sams Teach yourself Visual C++ .NET in 21 Days.
quote:Original post by mikef
I was wondering if it is possible to use MFC and STL at the same time

Yes.
quote:
and if so are there any benefits of doing so.

You get to use standard C++ for the core of your application and limit MFC to only where it is necessary. It''s up to you to decide if that is a benefit.
quote:
Also, would you guys recomend learning the win32 api before learning MFC?

I''d recommend learning the Win32 API *over* learning MFC.
To answer your other question, I''d recommend learning at least the basics of Win32 before moving on to MFC.
quote:original quote by SabreMan:
You get to use standard C++ for the core of your application and limit MFC to only where it is necessary. It''s up to you to decide if that is a benefit.


If you want to use MFC, it becomes the core of your application. You can''t simply use parts of it. Also, whether you write your program with pure API calls or the MFC framework, you are using standard C++. STL is just one part of C++ (a template library, hence the name). C++ is a language. MFC is a library of C++ classes that encapsulate the Win32 API.

You should definetly learn the Win32 API before learning MFC. MFC has its uses, but in order to get a firm grasp on how Windows works, you should learn the API.

-Mike
quote:You should definetly learn the Win32 API before learning MFC. MFC has its uses, but in order to get a firm grasp on how Windows works, you should learn the API.


I disagree with that. It''s like saying you need to learn C before learning C++. In either case, it just comes down to what you''re comfortable with. I prefer calling methods of a CWnd object to calling a global function and passing in a HWND, so I use MFC.

I highly recommend reading MFC Internals by Scot Wingo & George Shepherd (I think...I''m away from my copy right now). This book is amazing! It really clears up a lot of what goes on behind the scenes in MFC, and greatly improves your ability to use it.
quote:Original post by doctorsixstring
If you want to use MFC, it becomes the core of your application.

Only if you make it so. In an architecture resembling model-view-controller (for example), it''s common to perceive the model as the functional core, with MFC being a potential candidate technology to implement the view. The idea of such an architecture is that either the model or view can be changed for another with only the controller layer having to change to handle the interactions. Allowing MFC classes into the controller layer obviously compromises the ability to cleanly switch to a different platform library.
quote:
You can''t simply use parts of it.

Of course you can. Are you saying you must use either all of it or none of it?
quote:
Also, whether you write your program with pure API calls or the MFC framework, you are using standard C++.

MFC and Win32 are both APIs which are not defined by the C++ Standard. MS provide C++ extensions with their compiler, and their libraries will not compile with those extensions turned off. In fact, their C++ Standard libraries depend on extensions, but at least those extensions don''t have to appear in user code. If you are writing an MFC application the way MS would have it, you are writing MS C++, *not* Standard C++. The point I''m making is that it depends on the project whether that is an issue.
quote:
STL is just one part of C++ (a template library, hence the name). C++ is a language.

And a library. The C++ Standard defines both.
quote:Original post by SabreMan
Of course you can. Are you saying you must use either all of it or none of it?



If you would kindly make a .dsw or .sln of a project that just uses "a little bit" of MFC, zip it up, and send it to bross_46@hotmail.com, I''d really appreciate it.

I''ve been trying to use just a little bit of MFC without using the whole god damn thing for years now.
daerid@gmail.com
I can''t see the point to use CString with STL, since std::string is far more powerful than CString.
If you have to use both at the same time, go for std::string.

(MFC is useful to make dialog windows)


Darkhaven Beta-test stage coming soon.

This topic is closed to new replies.

Advertisement