View Single Post
  #1 (permalink)  
Old April 6th, 2006, 11:28 PM
varun varun is offline
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default passing an object to a manipulator function

hello friends,

i want to pass an object as an argument as follows.

#include <iomanip>
#include <iostream>
using namespace std;

class myclass
{
public :
    int m,n;

    myclass(){m=10;n=12;}
};

ostream & disp( ostream & output,myclass &obj)
{
output<<"Hello"<<endl;
output<<obj.m;
return output;
}

void main()
{
myclass myobjct;
cout<<disp<<myobjct;
}


Above code does not run.
How to achieve above feature ?

plase help me. its urgent.
thank you.
Reply With Quote