Method called by Pointer to Vector can't modify object

I've been searching for a similar problem on the web but I could not find anything helpful, here's the Problem:

When DeleteConnectedEdges calls Method1 on Element 1 of the Vector Edges it seems Method1 can't modify data but there's no error saying so.

How can I make this work? Thank you very much.

int main(int argc, char** argv) {
std::vector<GenericEdgeClass> Edges;
...
}

class GenericNodeClass {
private:
    std::vector<GenericEdgeClass> *Edges;
public:
    GenericNodeClass(
        std::vector<GenericEdgeClass> *EdgesPtr,
        Point3DClass position,
        ID_TYPE new_ID);
    virtual ~GenericNodeClass();
    ID_TYPE ID;
    void DeleteConnectedEdges() {
             ((GenericEdgeClass)(*Edges)[1]).Method1();
    }
};

Answers


((GenericEdgeClass)(*Edges)[1]).Method1();
 ^^^^^^^^^^^^^^^^^^

What is that cast doing there? That causes the function to be called on a temporary copy of the object in Edges, not the object itself, which is why you don't see whatever modification it's supposed to make. The fix is simply to get rid of it:

(*Edges)[1].Method1();

Need Your Help

Fixing .NET code generation of properties for user controls

c# .net visual-studio winforms user-controls

I have a property of type IEnumerable&lt;SomeClassIWrote&gt; in a user control. When I use this control in a GUI, the .Designer.cs file contains the line:

The ConnectionString property has not been initialized error with VB.NET

vb.net runtime-error connection-string

I am trying to fill a datagrid with data from access, but every time I run this program i get an error saying ConnectionString property has not been initialized i have tried everything i know. Can