问题
I'm using omnetpp-5.4.1 , veins-4.7.1 , sumo-0.30.0 .I'm going to do fuzzy clustering by RSU in veins.I created a new module called FCM in veins/modules/application/traci and inherited the TraCIDemo11p and wrote the clustering code in it. Because I want to RSU start clustering,I used the initialize method in the TraCIDemoRSU11p to call the method inside the FMC at the start of work.
void TraCIDemoRSU11p::initialize(int stage) {
BaseWaveApplLayer::initialize(stage);
std::cout<<"starting clustering";
FCM * fcm_clustering;
fcm_clustering->clustering();
}
When I run the program, it is not allowed to run at the start of the program, saying "finish with error" and the program stops running. What can I do to call the clustering by RSU at the beginning of the simulation?
please help me to solvemy problem. Thanks.
回答1:
You have defined a pointer fcm_clustering
but you didn't initialize it. Therefore an attempt to use it ends up with memory violation.
Try to create FCM
object, for example:
FCM * fcm_clustering = new FCM();
来源:https://stackoverflow.com/questions/57933719/initialize-method-in-tracidemorsu11p