setting parameter in setprecision

Dear Friends,

I have created a class. In this class there is my own display function. I have created two objects of the same class. Now I want to print these objects using display function but only object 2 will use setprecision manipulator.

how to make it?

If I have defined the setprecision in display function then any object calling display function will use setprecision.How to make sure that only object 2 uses setprecision? while both objects calls the same display function.

regards
Add a bool member to handle this thing
Dear Frind,

Thanks for your answer but I m very beginner can you show me an example:

See my function
//Defining Display Function;
void mycalss::Display()
{

cout<<"\n\t"<<"Object-1: "<<endl;
cout<<"\n\t"<<"Input : ";
cout<<setfill('*')<<setw(25)<<"Base = "<<base<<" , "<<"Hight = "<<hight<<endl;
cout<<"\t"<<"Area of Object 1 = "<<setfill('*')<<setw(12)<<area;
}

object1.display();
object2.display();

Regards
closed account (N85iE3v7)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void mycalss::Display(bool SetPrecision)
{
    if ( SetPrecision == true )
    {
        // code that uses precision settings
    }
    else
    {
        // otherwise don't require settings
    }
}

// when calling
object1.display(true);
object2.display(false);

Thanks a lot dear I got it
Topic archived. No new replies allowed.