STL and MFC

P

pkirk25

Hi all,

I want to put a simple GUI with 3 combo boxes and a datagrid on my
little app that looks at World of Warcraft auction data. Ideally I
want my app to have the work done in a STL based class and the GUI do
be just data and display.

I have Visual C++6 and am wading through the MFC tutorial. So far the
thing that has me most concerned is the risk of namespace collisions.

For example, there is a vector template. Is it the STL vector thrown
in with MFC for free? Likewise a sting class.

Is there any issue with passing CString to stl string? Or to fstream
whiuch looks for char *filename?
 
E

Earl Purple

pkirk25 said:
Hi all,

I want to put a simple GUI with 3 combo boxes and a datagrid on my
little app that looks at World of Warcraft auction data. Ideally I
want my app to have the work done in a STL based class and the GUI do
be just data and display.

I have Visual C++6 and am wading through the MFC tutorial. So far the
thing that has me most concerned is the risk of namespace collisions.

For example, there is a vector template. Is it the STL vector thrown
in with MFC for free? Likewise a sting class.

Is there any issue with passing CString to stl string? Or to fstream
whiuch looks for char *filename?

STL is part of the standard C++ libraries so it comes with any C++
compiler post 1998, but VC6 is not the most compliant compiler. I don't
know why so many are still using it.

MFC's CString and their CFile etc classes were created before the days
of a C++ standard which explains why there is more than one way of
doing things. In addition, CString has a slight advantage of being
proprietary to MFC and not a template, so it is happily portable across
libraries. Qt and WxWiidgets also use their own proprietary strings.

This is the wrong message board for discussing MFC though.
 
G

Gavin Deane

pkirk25 said:
Hi all,

I want to put a simple GUI with 3 combo boxes and a datagrid on my
little app that looks at World of Warcraft auction data. Ideally I
want my app to have the work done in a STL based class and the GUI do
be just data and display.

Sounds like a good plan.
I have Visual C++6 and am wading through the MFC tutorial. So far the
thing that has me most concerned is the risk of namespace collisions.

It's a while since I used the MFC library, and discussion of it is
off-topic here. However, what I do remember is that the naming
convention in the MFC library involves CamelCase while the naming
convention in the C++ standard library does not, and, more importantly,
while the MFC library is dumped into the global namespace, the C++
standard library is not. Because everything is in the std namespace,
the one problem you should never have when using the standard library
is name collision.
For example, there is a vector template. Is it the STL vector thrown
in with MFC for free? Likewise a sting class.

As is required of any C++ compiler, VC++6 provides a header called
<vector> which declared std::vector and a header called <string> which
declares std::string. VC++6 is quite old so you may find quality of
implementation issues with them (I can't remember any specifically and
detailed discussion would belong in a VC++6 group).

I think you have some misunderstanding between compilers and libraries.
The C++ standard library is not "thrown in with MFC", for free or
otherwise. It is "thrown in for free" with the compiler (VC++6),
because C++ compilers are required to throw in the standard library for
free. The MFC library is "thrown in", probably not for free, with
whichever package it is that you have bought that also includes the
VC++6 compiler (I guess some version of MS Visual Studio).
Is there any issue with passing CString to stl string? Or to fstream
whiuch looks for char *filename?

CString is an MFC class. The MFC documentation or an MFC programming
newsgroup is the place to ask how to use it.

Gavin Deane
 
J

jjds101

pkirk25 said:
Hi all,

I want to put a simple GUI with 3 combo boxes and a datagrid on my
little app that looks at World of Warcraft auction data. Ideally I
want my app to have the work done in a STL based class and the GUI do
be just data and display.

I have Visual C++6 and am wading through the MFC tutorial. So far the
thing that has me most concerned is the risk of namespace collisions.

For example, there is a vector template. Is it the STL vector thrown
in with MFC for free? Likewise a sting class.

Is there any issue with passing CString to stl string? Or to fstream
whiuch looks for char *filename?

You may also want to note that although MFC is not included with Visual
C++ express, you can atill use the MFC libraries you already have from
VC++6 with the latest VC++ Express compiler. You'd need to modify the
include paths in VC++Exp -- check with an MS newsgroup or forum for
more info on that.

That way you'd have a more updated, standards-compliant compiler and
still keep the MFC libraries.
 
P

pkirk25

Thanks.

Would downloading an up to date STL implementation be a good idea or
will that just confuse the compiler?
 
G

Gavin Deane

pkirk25 said:
Thanks.

Would downloading an up to date STL implementation be a good idea or
will that just confuse the compiler?

If you were to replace the standard library implementation that came
with your compiler with a different one from another source, you would
need to check that the new one was designed for your compiler otherwise
it probably wouldn't work at all. A VC++ newsgroup should be able to
tell you what other implementations targeting your compiler might be
out there.

Gavin Deane
 
P

pkirk25

pkirk25 said:
[snip]
You may also want to note that although MFC is not included with Visual
C++ express, you can atill use the MFC libraries you already have from
VC++6 with the latest VC++ Express compiler. You'd need to modify the
include paths in VC++Exp -- check with an MS newsgroup or forum for
more info on that.
Oddly C++ Express comes with STL but without MFC. Thats why I switched
back to VC6.
 
G

Gavin Deane

pkirk25 said:
pkirk25 said:
[snip]
You may also want to note that although MFC is not included with Visual
C++ express, you can atill use the MFC libraries you already have from
VC++6 with the latest VC++ Express compiler. You'd need to modify the
include paths in VC++Exp -- check with an MS newsgroup or forum for
more info on that.
Oddly C++ Express comes with STL but without MFC. Thats why I switched
back to VC6.

I don't think there is anything odd about that. I still wonder if
you're confused about where C++ stops and proprietary starts.

By definition, it is not possible for a C++ compiler to not come with
the standard library. The standard library is part of C++ so anything
that does not come with a standard library implementation is not a C++
compiler. So it's not odd that VC++6 and VC++8 (the compiler under the
free VC++ Express IDE) both come with it.

MFC on the other hand is a proprietary library owned by Microsoft. The
drag and drop graphical GUI development tool is also a proprietary
product owned by Microsoft. It is entirely up to them whether to make
that library and product available for free and they have chosen not
to. I don't think there's anything necessarily odd about that either.

Gavin Deane
 
J

jjds101

pkirk25 said:
pkirk25 said:
[snip]
You may also want to note that although MFC is not included with Visual
C++ express, you can atill use the MFC libraries you already have from
VC++6 with the latest VC++ Express compiler. You'd need to modify the
include paths in VC++Exp -- check with an MS newsgroup or forum for
more info on that.
Oddly C++ Express comes with STL but without MFC. Thats why I switched
back to VC6.

Right. I'm just saying you didn't need to switch to an older compiler
just to use a library. Just use the MFC library from VC6 with the
newer VCE compiler.
 
M

Martin Steen

Gavin said:
MFC on the other hand is a proprietary library owned by Microsoft.

And it's outdated, too. .NET is "state of the art" by now.

BTW: this is what Nicolai Josuttis (author of the book "The C++ Standard
Library") says about Visual C++:

"
Neither Visual C++ 5.0 nor Visual C++ 6.0 nor Visual C++ .NET (Version
7.0, before 2003) are standard-conforming. For this reason, some
examples of my books don't compile.
"

Best regards, Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top