From: Doug Harrison [MVP] on
On Mon, 10 May 2010 14:21:06 -0400, "RB" <NoMail(a)NoSpam> wrote:

> cout << array[j] << endl; //error C2065: 'cout' : undeclared identifier

The identifiers cout and endl are also in namespace std, so you need to
say:

std::cout << array[j] << std::endl;

Kind of a pain, but you could employ using-declarations to ease things:

using std::cout;
using std::endl;

This brings just these symbols into scope. That said, I don't know how
useful cout is in an MFC program...

--
Doug Harrison
Visual C++ MVP
From: RB on

> Doug Harrison wrote
> The identifiers cout and endl are also in namespace std, so you need
> std::cout << array[j] << std::endl;
> Kind of a pain, but you could employ using-declarations to ease things:
> using std::cout;
> using std::endl;
> This brings just these symbols into scope. That said, I don't know how
> useful cout is in an MFC program... Doug Harrison

Ohh... ok. Well you're right don't really need cout much it was just in the
sample code. I have been trying another sample for CMap which was
something I wanted to learn but my VC 6 compiler will not compile it.
Even though I have the #include <afxtempl.h> it will not acknowledge it.
The browser doesn't find CMap either with a BrowseGotoDefinition key
for whatever that's worth, not much as Joe would say.

CMap<CStrng, CString&, CPoint, CPoint&> MyMap2; //error C2065: 'CStrng' : undeclared identifier
MyMap1[CString (_T ("Vertex1"))] = CPoint ( 0, 0);

It may be the sample though because this will compile and browse
CMapStringToString MyMap2; // compiles ok

The first sample may be flawed, but it looked interesting since it will allow
a user defined type into CMap. I looked at structs in std::map but I am
so weak in template language that I will probably just have to pull off and
read some text for a few days. I have a legal bought copy of VC 2005 and
I am definitely going to install it this weekend. I dread getting acclimated
to a new environment since I had grown so used to the old VC 6.
Thanks for the help guy.


From: Joseph M. Newcomer on
You can't really use CString in a non-MFC app without including <atlstring.h>; if you have
not included that, then you won't have CString defined. Note that none of this has
anything to do with the std:: namespace, but with the failure to have included the string
library.

You should not mix MFC and non-MFC idioms in non-MFC programs. It is OK to use std:: in
an MFC program, but not to use MFC constructs in a non-MFC program. Note that if you are
generating a console app, you can check the "use MFC" option when you create the app, and
you will get all of the MFC library (which is overkill for a console app). Or you can
figure out which ATL header files need to be included to get the capabilities you need.

But the odd mix, that includes CString and cout, is more than a little weird.
joe

On Mon, 10 May 2010 18:38:40 -0400, "RB" <NoMail(a)NoSpam> wrote:

>
>> Doug Harrison wrote
>> The identifiers cout and endl are also in namespace std, so you need
>> std::cout << array[j] << std::endl;
>> Kind of a pain, but you could employ using-declarations to ease things:
>> using std::cout;
>> using std::endl;
>> This brings just these symbols into scope. That said, I don't know how
>> useful cout is in an MFC program... Doug Harrison
>
>Ohh... ok. Well you're right don't really need cout much it was just in the
>sample code. I have been trying another sample for CMap which was
>something I wanted to learn but my VC 6 compiler will not compile it.
>Even though I have the #include <afxtempl.h> it will not acknowledge it.
>The browser doesn't find CMap either with a BrowseGotoDefinition key
>for whatever that's worth, not much as Joe would say.
>
>CMap<CStrng, CString&, CPoint, CPoint&> MyMap2; //error C2065: 'CStrng' : undeclared identifier
>MyMap1[CString (_T ("Vertex1"))] = CPoint ( 0, 0);
>
>It may be the sample though because this will compile and browse
>CMapStringToString MyMap2; // compiles ok
>
>The first sample may be flawed, but it looked interesting since it will allow
>a user defined type into CMap. I looked at structs in std::map but I am
>so weak in template language that I will probably just have to pull off and
>read some text for a few days. I have a legal bought copy of VC 2005 and
>I am definitely going to install it this weekend. I dread getting acclimated
>to a new environment since I had grown so used to the old VC 6.
>Thanks for the help guy.
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Faisal on
On May 11, 3:38 am, "RB" <NoMail(a)NoSpam> wrote:
> > Doug Harrison wrote
> > The identifiers cout and endl are also in namespace std, so you need
> >   std::cout << array[j] << std::endl;
> > Kind of a pain, but you could employ using-declarations to ease things:
> > using std::cout;
> > using std::endl;
> > This brings just these symbols into scope. That said, I don't know how
> > useful cout is in an MFC program... Doug Harrison
>
> Ohh... ok. Well you're right don't really need cout much it was just in the
> sample code. I have been trying another sample for CMap which was
> something I wanted to learn but my VC 6 compiler will not compile it.
> Even though I have the #include <afxtempl.h> it will not acknowledge it.
> The browser doesn't find CMap either with a BrowseGotoDefinition key
> for whatever that's worth, not much as Joe would say.
>
> CMap<CStrng, CString&, CPoint, CPoint&> MyMap2; //error C2065: 'CStrng' : undeclared identifier

Did you see the error message
CStrng' : undeclared identifier

You have to type CString :)

> MyMap1[CString (_T ("Vertex1"))] = CPoint ( 0,  0);
>
> It may be the sample though because this will compile and browse
> CMapStringToString   MyMap2; // compiles ok
>
> The first sample may be flawed, but it looked interesting since it will allow
> a user defined type into CMap. I looked at structs in std::map but I am
> so weak in template language that I will probably just have to pull off and
> read some text for a few days. I have a legal bought copy of VC 2005 and
> I am definitely going to install it this weekend. I dread getting acclimated
> to a new environment since I had grown so used to the old VC 6.
> Thanks for the help guy.

From: Giovanni Dicanio on
"RB" <NoMail(a)NoSpam> wrote:

> CMap<CStrng, CString&, CPoint, CPoint&> MyMap2; //error C2065: 'CStrng' :
> undeclared identifier
> MyMap1[CString (_T ("Vertex1"))] = CPoint ( 0, 0);

If you use std::map, you have to specify only two template arguments instead
of four: just the key type and the value type:

#include <map> // Use STL map container

std::map< CString, CPoint > MyMap;
MyMap[ _T("Vertex1") ] = CPoint(0, 0);


> I have a legal bought copy of VC 2005 and
> I am definitely going to install it this weekend.

Good move!


> I dread getting acclimated
> to a new environment since I had grown so used to the old VC 6.

You will miss VC6's ClassWizard and snappy IDE, but you will get several
good things, like a better C++ compiler, better libraries, and debugging
visualizers.


Giovanni