Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revised the Vector constructor #11

Open
GoogleCodeExporter opened this issue Mar 23, 2015 · 6 comments
Open

Revised the Vector constructor #11

GoogleCodeExporter opened this issue Mar 23, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link

While calling the constructor of the vector with size 0, it gives an
ambiguous result. Is it appropriate? Or can it be solved.

Vector p(0);

mincut_test.cpp:35: error: call of overloaded ‘BasicVector(int)’ is 
ambiguous


Also, the default constructor seems give a segfault.

Vector p;
p.print();


I think it should be mentioned in the documentation. Or adding a null state
vector support.

Original issue reported on code.google.com by lau65...@gmail.com on 10 Jul 2009 at 6:44

@GoogleCodeExporter
Copy link
Author

The problem is 0 can be either an integer or a NULL pointer.

The default constructor shouldn't be called. Use Vector::n() instead.

Original comment by kennytm@gmail.com on 10 Jul 2009 at 11:49

@GoogleCodeExporter
Copy link
Author

So let me find some method to solve it.

Original comment by lau65...@gmail.com on 10 Jul 2009 at 4:41

@GoogleCodeExporter
Copy link
Author

Can you block the use of default constructor for non-friend class? Or you may 
change
it to initialize a vector of zero size.

It always create a potential trap of segmentation fault.

Original comment by lau65...@gmail.com on 11 Jul 2009 at 7:10

@GoogleCodeExporter
Copy link
Author

The Vector now allow the pass of Vector(0) with int type. I think it is what we 
want,
you may check about the use of it.

I don't know whether the trick is support by all compile or it is standard. 
Check
int_ptr_overload.cpp

Original comment by lau65...@gmail.com on 11 Jul 2009 at 7:14

@GoogleCodeExporter
Copy link
Author

@4:

Is that r104 & r105?

Original comment by kennytm@gmail.com on 24 Jul 2009 at 3:11

@GoogleCodeExporter
Copy link
Author

r105, I just change the long to int and it works.

Original comment by lau65...@gmail.com on 25 Jul 2009 at 3:58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant