Click here to Skip to main content
15,501,036 members

Comments by «_Superman_» (Top 84 by date)

«_Superman_» 4-Jul-18 22:36pm View     CRLF
>> Is this because it is like writing: >> list1.operator=(list2.operator=(list3.operator=(list4))) That is correct. >>But the insert method doesnt take p_itr as a parameter so it can not modify it, it takes a value pointed to by p_itr. I was referring to what could be done with pre-processor macros like in this link - The OFFSETOF() macro - GeeksforGeeks[^] But it probably does not apply here. You could try and debug the code to check what is actually happening. >>Is operator=(const Player& other); a valid definition In C++ it is not. In C, int is assumed as the return type if nothing is specified. However this defeats the purpose since you're trying to make a copy of the object, unless you have a single integer argument conversion constructor.
«_Superman_» 6-Oct-17 0:58am View     CRLF
I executed your code and got the output given below. What is your question? Enter the coordinates of point 1: 2.3 4.5 Enter the coordinates of point 2: 6.7 8.6 The slope of the line is = 0.93182 The slope intercept form is: y = 0.93182x + 2.35682
«_Superman_» 4-Oct-17 4:43am View    
Definitely yes. But std::sort is tried and tested. Who knows how it is going to be optimized in future. Having said that, after experimenting, if the performance makes a huge difference, then would definitely get rid of std::sort.
«_Superman_» 4-Oct-17 4:34am View    
I agree. For this case iterating once over the list would indeed be the fastest.
«_Superman_» 4-Oct-17 4:23am View    
I would still prefer sort to having if conditions inside a loop.