Troubles with calling object
Hi,
I have two classes, Ring and Node.
Class Ring have an object called ring1 and class Node have an object called no1.
At main(), I make an instance of ring, ring1, and call his method create_network().
Insite create_network I need to make an instance of Node, no1. How can I make this?
1 2 3 4
|
class Ring {
public:
void create_network(int);
};
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
class Node
{
public:
void setlambIn(int);
float setLambInNextIteration(int,int,int);
//void setlambIn(void);
void setlambClass1(void);
void setlambClass2(void);
void setlambClass3(void);
void setlambOut(void);
void setOutgoingNetRateInNode(void);
void setCrossingNodeRate(void);
void setIncomingNetRateInNode(void);
};
|
1 2
|
Ring ring1;
ring1.create_network(numNos);
|
1 2 3 4 5 6
|
void Ring::create_network(int numNos) {
cout << "\n test \n";
Node no1;
no1.setlambIn(numNos);
};
|
Last edited on
I reckon you could try returning an adress to the instance you create within the function
1 2 3 4 5 6 7
|
Node* Ring::create_network(int numNos) {
cout << "\n peitinho \n";
Node* no1 = new Node;
no1->setlambIn(numNos);
// Additional code
return no1;
}
|
Last edited on
Thank`s for you attention!!
[]'s Drika
Topic archived. No new replies allowed.