|
-
February 3rd, 2003, 11:32 PM
#1
Meeting troubles when compiling simple STL program.
Hi, everyone!
I meet with the following trouble when compiling the
following simple STL program.
The error message is, ostream_iterator undeclared.
My IDE is VC 6.0.
Here are the source codes,
--------
#include "iterator"
#include "iostream"
void main()
{
ostream_iterator<int> r (cout);
*r = 0;
}
--------
Thanks in advance,
George
-
February 4th, 2003, 03:27 AM
#2
dont forget to write
either
std:: ostream_iterator r;
or
using namespace std;
aafter the #includes
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames
-
February 4th, 2003, 04:06 AM
#3
Everything of the STL is declared within the namespace 'std'. Therefore you need to map the namespace to your application as mentioned.
The following shows you the four different methods to map a namespace...
Code:
// 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'
-
February 4th, 2003, 04:14 AM
#4
Thanks!
Originally posted by Andreas Masur
Everything of the STL is declared within the namespace 'std'. Therefore you need to map the namespace to your application as mentioned.
The following shows you the four different methods to map a namespace...
Code:
// 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'
-
February 4th, 2003, 04:16 AM
#5
Originally posted by Andreas Masur
Everything of the STL is declared within the namespace 'std'. Therefore you need to map the namespace to your application as mentioned.
The following shows you the four different methods to map a namespace...
Code:
// 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'
-
February 4th, 2003, 04:18 AM
#6
Thanks, SeventhStar buddies!
George
Originally posted by SeventhStar
dont forget to write
either
std:: ostream_iterator r;
or
using namespace std;
aafter the #includes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|