M
ma740988
There's no way to use the STL algorithm copy to print an outfile
(essentially an ofstream)? So now:
int main()
{
std::ifstream InFile( "exercise15.txt");
std:fstream ToFile( "NewFile.txt" );
////////////////////////////
// Alternative 1
// ToFile << InFile.rdbuf();
////////////////////////////
// Alternative 2
std::copy( istream_iterator<string>(InFile),
istream_iterator<string>(),
ostream_iterator<string>( ToFile, "\n" ) );
// How do I print whats in the 'ToFile'??? Perhaps some other algo?
return 0;
}
Assume the contents of InFile are as follows:
1 2 3 4 5
4 5 6 7 8
The fact that ToFile reflects InFile is a good thing but I'd have
thought the call to ostream_iterator with the '\n' delimeter would
make the contents.
1
2
3
4
etc
////////
Consider this statement:
1 Constructors do not have names. A special declarator syntax using
an
optional function-specifier (_dcl.fct.spec_) followed by the
construc-
tor's class name followed by a parameter list is used to declare
or
define the constructor. In such a declaration, optional
parentheses
around the constructor class name are ignored. [Example:
class C {
public:
C(); // declares the constructor
};
C::C() { } // defines the constructor
--end example]
Where function specifiers is defined as
1 Function-specifiers can be used only in function declarations.
function-specifier:
inline
virtual
explicit
What is this 'special declaration syntax'? Secondly, am I led to
believe - hence the 'optional function specifier' - that for a
constructor I could do
explicit class C
{
// stuff
};
(essentially an ofstream)? So now:
int main()
{
std::ifstream InFile( "exercise15.txt");
std:fstream ToFile( "NewFile.txt" );
////////////////////////////
// Alternative 1
// ToFile << InFile.rdbuf();
////////////////////////////
// Alternative 2
std::copy( istream_iterator<string>(InFile),
istream_iterator<string>(),
ostream_iterator<string>( ToFile, "\n" ) );
// How do I print whats in the 'ToFile'??? Perhaps some other algo?
return 0;
}
Assume the contents of InFile are as follows:
1 2 3 4 5
4 5 6 7 8
The fact that ToFile reflects InFile is a good thing but I'd have
thought the call to ostream_iterator with the '\n' delimeter would
make the contents.
1
2
3
4
etc
////////
Consider this statement:
1 Constructors do not have names. A special declarator syntax using
an
optional function-specifier (_dcl.fct.spec_) followed by the
construc-
tor's class name followed by a parameter list is used to declare
or
define the constructor. In such a declaration, optional
parentheses
around the constructor class name are ignored. [Example:
class C {
public:
C(); // declares the constructor
};
C::C() { } // defines the constructor
--end example]
Where function specifiers is defined as
1 Function-specifiers can be used only in function declarations.
function-specifier:
inline
virtual
explicit
What is this 'special declaration syntax'? Secondly, am I led to
believe - hence the 'optional function specifier' - that for a
constructor I could do
explicit class C
{
// stuff
};