Type: Posts; User: Philip Nicoletti
Search took 0.14 seconds.
Are you sure that you copied that function correctly ?
January 17th, 2015, 04:20 AM
In less I am missing something, none of them should compile. The third parameter to find_if() is wrong in all cases. It should be a predicate.
1) You have sets with pointers as elements. That...
January 16th, 2015, 11:46 AM
Could you explain this further ?
Are you saying:
if (m1.end() == m2.end()) // this is possible
January 15th, 2015, 05:37 PM
I don't think there is a real nice method.
1) Before reading your "please" comment, I was going to suggest optns.end() [ set after the clear() ]
2) use a separate bool variable
January 2nd, 2015, 06:23 AM
Something to check:
ofs_differential.write((char*)&bfh_warm, sizeof(bfh_warm) ); //write header
What is sizeof(bfh_warm) ? Is it 14, or 16 ?
Visual C++ has bitmap header structures...
December 12th, 2014, 01:19 PM
The bigger function that you supplied will not compile with the sort for result_holder.
monarch_dodra supplied an example to sort int variables. You would need to change it for variables of type...
December 12th, 2014, 01:14 PM
bool operator < (const result_holder& lhs, const result_holder& rhs)
return lhs.row_value > rhs.row_value;
December 12th, 2014, 06:49 AM
It depends on the object. You need to provide more information .
1) You might not to add any additional code to a class to copy an object.
2) You might need to add copy semantics to your...
December 10th, 2014, 07:31 PM
If you make operator < a member function, it should only take one argument and be const:
bool operator < (const result_holder& rhs) const
return row_value < rhs.row_value;
December 10th, 2014, 06:37 AM
for (int q=0; q=size2;q++)
This sets q = size2 every time thru the loop (and the loop never terminates)
December 1st, 2014, 08:04 PM
It is not clear how the first two elements are equal. I guess if the second values of the pair are equal ?
November 26th, 2014, 10:30 AM
You can access using:
for (vector<SP>::const_iterator it4=it->sl4.begin(); it4!=sl4.end(); ++it4)
cout << it4->sp1 << " : " << it4->sp2 << "\n";
November 25th, 2014, 06:21 PM
size_t find (char c, size_t pos = 0) const noexcept;
size_t is an unsigned integral type (the same as member type...
November 25th, 2014, 11:33 AM
1) you should #include <string>
2) the type returned by string::find is string::size_type , not double
3) in general, erasing an element while looping is tricky
November 17th, 2014, 08:15 AM
1) You need to open the file as binary. Otherwise, if an EOF character is encountered, input will stop.
std::string can handle embedded NULLS.
November 11th, 2014, 12:09 AM
That is interesting that a run time error occurs in the first example.
It must occur during the copy when passing x by value. In other
words, I would guess you would still get the error even if...
November 10th, 2014, 12:03 PM
Sorry, with further thought my original suggestion would not work.
November 9th, 2014, 05:00 PM
while(high>low and high!=low)
is legal. There are a number of alternate tokens like this ("bitor" , "xor" , "or" , etc).
Personally, I would not use them as they are seldom seen in code.
October 31st, 2014, 05:57 PM
1) I was not aware of the "= default" syntax ... good to know
2) Unless I am missing something, it might be safer to supply them. Section 12.8.10 :
edit: Upon re-reading the note, I think...
October 31st, 2014, 03:39 PM
Here is an example of a 2D array class using a single vector<T> as a member.
Element access is done using : arr((i,j) not arr[i][j]
I added move semantics. You should add move semantics to your...
October 31st, 2014, 02:30 PM
Yes, basically that is correct. Your code in the original post was for a 3D array, so it will call the constructor O(n^2) times.
October 31st, 2014, 07:04 AM
This is a simple, but inefficient way to create multi-dimensional
arrays. As you noticed, the constructor (and hence new) is called
October 28th, 2014, 07:59 PM
And in your code you have:
next = it+1;
The erase invalidates iterators and references at or after the point of the erase. So the "next" iterator has been invalidated.
October 28th, 2014, 07:43 PM
Your loop should look like this:
for(vector<int>::iterator it=v.begin();it!=v.end();/* nothing here*/)
if(*it == 14)
it = v.erase(it);
October 26th, 2014, 06:05 PM
I don't see that. operator= decrements the reference count and if equals 0, deletes the memory. Am I missing something ?
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.