Search:
Type: Posts; User: phl
Search:
Search took 0.06 seconds.
-
January 31st, 2008, 06:43 PM
Corrections are in red.
int main(){
//i can do it like this
int** p;
p = new int*[10];
for(int i=0;i<10;i++)
p[i] = new int[10];
-
January 29th, 2008, 10:53 AM
Yes, passing is the right choice of word, not converting.
-
January 29th, 2008, 10:48 AM
Because it first creates a temporary of abc by calling constructor abc(char*), and then that temporary is passed by value to operator=(abc). Maybe you can run a debugger to see what's happening.
...
-
January 29th, 2008, 03:24 AM
I don't understand what you mean by "without checking its type", but here is what I think is happening.
anotherObject = "i Know why this works now!!!"; //
anotherObject = 8; ...
-
January 24th, 2008, 10:43 PM
Is std::vector<XButton*> the type of "buttons" in the following code ?
std::for_each(
buttons.begin(),
buttons.end(),
std::bind2nd(std::mem_fun_ref(&XButton::Update), event_));
-
January 22nd, 2008, 07:57 PM
solution[i] = new_y;
You are assigning new_y, which is of type double*, to solution[i], which is of type double.
-
January 22nd, 2008, 12:20 PM
Strictly speaking, this will not give the same result as the for-loop version when there is more than one element equal to "observer". The erase/remove idiom erases all of them, but the for-loop...
-
January 19th, 2008, 02:22 PM
You might want to take a look at boost graph library.
http://www.boost.org/libs/graph/doc/table_of_contents.html
You can use one of the shortest path algorithms on your problem and compare the...
-
January 17th, 2008, 06:09 PM
Make dashReplace return char*.
Alternatively, make dashReplace return nothing (return void). Since it is passing a pointer to line[12] as an argument, after dashReplace (line) is called, line[12]...
-
January 17th, 2008, 03:48 PM
1. In input.h, add "extern" to declare variables. Without "extern", it means you are defining variables, and since header files are most likely included multiple times, the compiler will complain the...
-
January 14th, 2008, 03:37 AM
Use bind2nd. In your example, mem_fun_ref returns a functor that takes 2 arguments, and bind2nd binds the second one to 0.
std::for_each (tests.begin (),
tests.end (),...
-
January 9th, 2008, 02:26 PM
Does it work if you change the order of the edges in the dataset?
For example, if you swap the 1st and the 6th edge, does it give the same results?
It seems to me that your code will print the 2...
-
January 9th, 2008, 01:29 PM
Your code is already simple enough (just 2 lines, if you get rid of the braces) so there is no need to make it more elegant. Also, I think your code might be better than the one using operator[], in...
-
January 9th, 2008, 01:18 PM
After comparing the weights, call a function that swaps the source and target if source > target (note that the original Edge is constant).
Edge order(const Edge& e) {
Edge tmp(e);
if...
-
January 9th, 2008, 12:07 AM
I agree. The original code is much easier to read, especially for those who don't use boost or STL often.
-
January 8th, 2008, 06:46 PM
If you are wiling to use boost::bind, the following code should accomplish what you want to do.
transform(objVec.begin(), objVec.end(), inserter(objMap, objMap.begin()),
...
-
January 3rd, 2008, 04:27 AM
Assuming you have a member of type B*,
class A {
public:
B* getInstB() {
return b;
}
private:
B* b;
-
December 23rd, 2007, 02:47 AM
If you are looking for an array you can resize, you might want to look into STL containers, such as vector or deque.
http://www.cplusplus.com/reference/stl/
-
December 21st, 2007, 03:30 PM
Use string or an array of size 2 to record the two characters previously read.
char ch;
string pre(" ");
while (TheFile.get(ch)) {
if (pre == ". ")
TheCopy.put(toupper(ch));
-
December 19th, 2007, 04:15 PM
You can write a template class as follows.
template<typename T>
struct ToConstRef {
typedef const T& _Type;
};
template<typename T>
-
December 10th, 2007, 09:12 PM
I cannot be sure since I don't understand how you are approaching the problem, but the following line looks like a mistake to me.
while...
-
December 7th, 2007, 01:09 PM
If the set contains pointers, use "mem_fun" instead. The following link gives an example.
http://www.sgi.com/tech/stl/mem_fun_t.html
The approach using remove_copy_if, as well as the one using...
-
December 7th, 2007, 01:46 AM
No, it doesn't.
http://www.sgi.com/tech/stl/set.html
-
December 7th, 2007, 12:57 AM
You can use mem_fun_ref when the predicate is a member function of the object stored in set.
#include <iostream>
#include <algorithm>
#include <iterator>
#include <set>
using namespace...
-
December 2nd, 2007, 07:50 PM
You don't need to make it a template. Just make it a plain old function.
class C {
public:
int f(char) {}
};
template <class Cl, typename R, typename P1>
|
Click Here to Expand Forum to Full Width
|