0

Not sure where I'm going wrong.. I have two classes like so:

class One
{
    public:
    vector<Object*> myObjects;
};

class Two
{
    public:
    vector<Object*> * pointertoObjects;
};

I then want to create a pointer from pointertoObjects to myObjects and am doing so like this:

pointertoObjects = &myObjects;

But when I try to access to pass through an element:

void doFunction(Object * object);
doFunction(pointertoObjects[i])

it gives me an error:

Error: no suitable conversion function from std::vector<Object *, std::allocator<Object *>>" to "Object *" exists

Where have I gone wrong?


You can correct the formatting with:

public static void main(String[] args) throws ParseException {
    String input = "20130401100000[-03:EST]";

    DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss'['Z':'z']'");
    df.setTimeZone(TimeZone.getTimeZone("GMT"));    

    System.out.println(df.format(new Date()));
    input = input.replace(":","00:");
    System.out.println(df.parse(input));
}

If you'll have correctly formatted dates mixed in with incorrectly formatted ones, you could use:

    input = input.replaceAll("(\\[[+-]\\d{2}):","$100:");
4

4 に答える 4

0

単純なタイプの不一致があります。で配列インデックスを使用すると、必要なではなくpointertoObjectsへの参照が取得されます。 vector<Object*>Object *doFunction

おそらく次のようなものが必要です。 doFunction((*pointertoObjects)[i]);

于 2013-05-28T16:14:15.567 に答える