S
stoptv
Hello group, this is my dilemma:
------------------------------------------------------------------------
#include <iostream>
using namespace std;
// a regular manipulator
ostream & hello( ostream & os ) { return os << "regular: hello"; }
struct Test // a manipulator wrapped inside a struct
{
ostream & hello( ostream & os ) { return os << "wrapped: hello"; }
};
int main( )
{
cout << hello << endl; // this works just fine..
Test t;
cout << t.hello << endl; // and this doesn't compile! WHY??
/* note: gcc 2.95.4 says there's no matching function to call,
* and then lists the possible applicators; but there it is:
*
* class ostream & ostream:
perator <<(ostream & (*)(ostream &))
*
* isn't that the wrapped manipulator's signature?
* I don't get it. Would anyone be so kind to explain? thanks!
*/
return 0;
}
------------------------------------------------------------------------
#include <iostream>
using namespace std;
// a regular manipulator
ostream & hello( ostream & os ) { return os << "regular: hello"; }
struct Test // a manipulator wrapped inside a struct
{
ostream & hello( ostream & os ) { return os << "wrapped: hello"; }
};
int main( )
{
cout << hello << endl; // this works just fine..
Test t;
cout << t.hello << endl; // and this doesn't compile! WHY??
/* note: gcc 2.95.4 says there's no matching function to call,
* and then lists the possible applicators; but there it is:
*
* class ostream & ostream:
*
* isn't that the wrapped manipulator's signature?
* I don't get it. Would anyone be so kind to explain? thanks!
*/
return 0;
}