How can I pass the array object?

Root

I am creating a structure as a data type What i basically want is to store the data which is line co-ordinates but when i pass two lines to find their distance and in arguments I pass the element of an array which is simple and the receiving argument is * how to resolve it.

This is the structure.

struct line_coordinates{
double x1,y1,x2,y2;
};

Here I am creating the array of a structure line_coordinates* array_line; Now calling the getdistance() and passing arguments

void initlize(vector<Vec2f> line1){
lines=line1;
array_line=new line_coordinates[lines.size()];
cout<<getdistance(array_line[0],array_line[1]);


double getdistance(line_coordinates *line1,line_coordinates *line2 )
{

 double midpointx1,midpointy1,midpointx2,midpointy2;
 midpointx1 =((line1->x1+line1->x2)/2);
 midpointy1=((line1->y1+line1->y2)/2);

 midpointx2 =((line2->x1+line2->x2)/2);
 midpointy2=((line2->y1+line2->y2)/2);
 double dist = sqrt(pow(midpointx2 - midpointx1, 2) + pow(midpointy2 - midpointy1, 2));
return dist;
}
Shoe

Let's see, array_line is of type line_coordinates*, that means that array_line[i] is of a type convertible to line_coordinates const&, which means that you should pass it by reference or by value instead:

double getdistance(line_coordinates const& line1,line_coordinates const& line2)
//                                  ^^^^^^                        ^^^^^^

Oh and by the way, please use std::vector.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I pass an object between functions

From Dev

How can I pass an object through $stateParams?

From Dev

How can I pass an object to my AsyncTask?

From Dev

How can I pass an object between functions

From Dev

How I can pass FormCollection object with $.ajax(...)

From Dev

How can I pass an initialized object

From Dev

How can i pass image array to JSONObject?

From Dev

How can I pass an array to a method?

From Dev

ContentTools - How can I pass additional data from a DIV to the payload object, to be passed into the POST array?

From Dev

can i pass array of properties on object.defineProperty()?

From Dev

How can I pass the same object to another method of another object?

From Java

How can I access an array/object?

From Dev

How can I use object as an array?

From Dev

How can I POST an object array with Jquery?

From Dev

How I can convert array to object in Javascript

From Dev

How can I push an array into an object

From Dev

how can i convert object into an array in javascript?

From Dev

How can i add object into static array

From Dev

How I can convert array to object in Javascript

From Dev

How can I retrieve the object into an array in Javascript?

From Dev

How can i convert array to SimpleXMLElement Object

From Dev

how can I add this object in an array?

From Dev

How can pass array list object from an activity to fragment in android

From Dev

How should I pass my prop to get a valid Array[Object]

From Dev

How should I pass my prop to get a valid Array[Object]

From Dev

How can I pass a QML object reference into Qt C++?

From Dev

How can I stop pass by reference an object stored in prototype?

From Dev

How can I pass a nested json object to rails from angular

From Dev

How can I pass an object from fetchedResultsController to a custom cell?

Related Related

  1. 1

    How can I pass an object between functions

  2. 2

    How can I pass an object through $stateParams?

  3. 3

    How can I pass an object to my AsyncTask?

  4. 4

    How can I pass an object between functions

  5. 5

    How I can pass FormCollection object with $.ajax(...)

  6. 6

    How can I pass an initialized object

  7. 7

    How can i pass image array to JSONObject?

  8. 8

    How can I pass an array to a method?

  9. 9

    ContentTools - How can I pass additional data from a DIV to the payload object, to be passed into the POST array?

  10. 10

    can i pass array of properties on object.defineProperty()?

  11. 11

    How can I pass the same object to another method of another object?

  12. 12

    How can I access an array/object?

  13. 13

    How can I use object as an array?

  14. 14

    How can I POST an object array with Jquery?

  15. 15

    How I can convert array to object in Javascript

  16. 16

    How can I push an array into an object

  17. 17

    how can i convert object into an array in javascript?

  18. 18

    How can i add object into static array

  19. 19

    How I can convert array to object in Javascript

  20. 20

    How can I retrieve the object into an array in Javascript?

  21. 21

    How can i convert array to SimpleXMLElement Object

  22. 22

    how can I add this object in an array?

  23. 23

    How can pass array list object from an activity to fragment in android

  24. 24

    How should I pass my prop to get a valid Array[Object]

  25. 25

    How should I pass my prop to get a valid Array[Object]

  26. 26

    How can I pass a QML object reference into Qt C++?

  27. 27

    How can I stop pass by reference an object stored in prototype?

  28. 28

    How can I pass a nested json object to rails from angular

  29. 29

    How can I pass an object from fetchedResultsController to a custom cell?

HotTag

Archive