I have this struct which returns double value of x & y. I want one more datatype in return(with this double), suppose of type int.
How to get that?What modifications i should do in this struct ?
I have this struct which returns double value of x & y.
Can you explain what you mean by this? A struct doesn't return anything. A struct is a type of object which contains data members, and methods. Functions and methods return things, not structs.
3) I'm really confused by the logic of your operators. In your equality operator:
You're only comparing the y members. This means that, even if the two objects have different values for x, then your operator will report that they are the same. Is that what you really want? How does that make sense?
my list now shows(in increasing order of values of y)
eg:
(27.98,9.045)
(26.98,9.045)
(27.51,9.045)
(16.14,22.14)
Now My requirement is like this
for the same value of y, I have to arrange x in increasing order
from above list I want
(26.98,9.045)
(27.51,9.045)
(27.98,9.045)
(16.14,22.14)
only for the same value of y, I have to arrange x in increasing order
Thanks
I am inserting values using loop
Eg: for(int ii=0; ii<something;ii++)
{
arr.push_back(pointt(something[ii]).X,something[ii]).y));
}
Now i want to insert another dayatype in this struct
for(int ii=0; ii<something;ii++)
{
arr.push_back(pointt(something[ii]).X,something[ii]).y,something[ii].string));
}
I want one more datatype in return(with this double), suppose of type int. How to get that? What modifications i should do in this struct ?
In other words, you have a struct that already:
* has member x
* has member y
... and you don't know how to add a third member?
Why is it hard for me to understand how you have managed to add two members to the struct without being able to add more?
The types? Do you know that each member has its own type (despite the use of comma-separated list syntax for declaring x and y in one statement). The x is a double and the y is a double, but one member being a double does not force the other members to be doubles.
The std::sort() can be used for more than just the ascending order. It has a form that takes third argument -- "predicate" -- that will determine the ordering.
See http://www.cplusplus.com/reference/algorithm/sort/