Simple problem... for you
I'm just a beginner in C++.NET. Can you tell me what's wrong here?
#include "stdafx.h"
#include <fstream>
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Dzialaj";
return 0;
}
Builder says:
error C2065: 'cout' : undeclared identifier
I don't understand... the "iostream" library is added to stdafx... but even if I add this to this file it doesn't works...
[465 byte] By [
Sebz] at [2007-11-18 19:18:42]

# 1 Re: Simple problem... for you
Try:
std::cout << "Dzialaj";
or even:
std::cout << "Dzialaj" << std::endl;
# 2 Re: Simple problem... for you
As mentioned, you need to map the namespace 'std' to your application.
The following shows you the four different methods to map a namespace...
// Using the full member name, including the namespace it belongs to:
std::cout << "Hello World";
// By taking advantage of Using-Declarations:
using std::cout; // This declares cout in the current
// scope as synonym for std::cout
cout << "Hello World";
// By taking advantage of Using-Directives:
using namespace std; // Which specifies that the current
// scope can refer to names in the
// 'std' namespace without using
// full qualifiers. This is mostly
// used when porting legacy code.
cout << "Hello World";
// Using aliases:
namespace X
{
namespace Y
{
class Z { ... };
}
}
X::Y::Z // The full qualifier for 'Z' is
// 'X::Y::Z'
namespace w = X::Y; // This declares 'w' as an alias for
// namespace 'X::Y'
w::Z // Access 'Z' using 'w::Z'
# 3 Re: Simple problem... for you
Thank you. Now I understand...
I'll try to ask you more difficult question in the future... :)
Sebz at 2007-11-9 12:04:56 >

# 4 Re: Simple problem... for you
Hi,
cout is incuded in std namespace in c++.nte so if you inlude :
using namspace std;
just after "#include" will sort out your cout error
you do not need to do anything else;
this should sort out many of your problems with future applications
Malg
malg at 2007-11-9 12:05:51 >

# 5 Re: Simple problem... for you
Thank you...
Can you tell me how to declare a "string" and operate on it?
I remember AnsiString from Borland and remember also how easy it was to operate on it...
Is there any similar type in VC++ on which I could opetate as easy as it was in Borland C++ Builder...?
How can I use it? What libraries should I link in source files?
I tried to do that in many ways but it didn't work.
I suppose the problem is in some markups or inheritance (inherity) from upper libraries (what libraries?)...
Sorry for those simple questions but the Microsoft's help is not so easy to use as Borland's one... I'm trying to find any book about VC++.NET but there are no good publications in Polish...
:)
I need a book which will have informations about a forms and mathods related with forms, markups and others subjects related with creating aplications in VC++...
Greetings and once again THANK YOU ALL!
Sebz at 2007-11-9 12:06:58 >

# 6 Re: Simple problem... for you
#include atlstr.h> // there should be a "<" before atlstr but if I post it the line doesn't show up
...
CString mystring; // and now a little bit of dev-archive, google ... search ...
Hope it helps
# 7 Re: Simple problem... for you
It works... thanks... :thumb:
Sebz at 2007-11-9 12:09:02 >
