Suppose I have created a class new with arguments.I have declared this as object new1 in the main.
new new1(arguments).
Now what should i do if i want to change the values of new1 object's arguments.

Suppose I have created a class new with arguments.

You can't do this. new is a C++ keyword. You can't create classes or variables with keywords as names.

I have declared this as object new1 in the main.
new new1(arguments). Now what should i do if i want to change the values of new1 object's arguments.

If the data members are public, you can change them directly. If they are private you will have to write set functions that set the data member values.

If you don't understand my reply, go read a C++ tutorial on classes.

Since you didn't specify whether you understood, I'll try to explain it briefly. Say you have the following code:

class MyClass
{
public:
   int x, y;
   MyClass(int a = 0, int b = 0)
   {
      x = a; y = b;
   }
};

You can change the values with the following:

MyClass* m = new MyClass();
    m->x = 5;
    m->y = 4;

However, if x and y are private, you'll need something like the following:

class MyClass
{
    int x, y;
public:
    MyClass(int a = 0, int b = 0)
    {
        x = a; y = b;
    }
    void setX(int n)
    {
        x = n;
    }
    void setY(int n)
    {
        y = n;
    }
};

    // in code somewhere...
    MyClass* m = new MyClass();
    m->setX(5);
    m->setY(4);
This article has been dead for over six months. Start a new discussion instead.