Search found 584 matches

by Krzysztof Duleba
Sat Oct 21, 2006 3:58 am
Forum: Volume 110 (11000-11099)
Topic: 11051 - Dihedral groups
Replies: 8
Views: 2498

The restriction is that undefined behaviour (such as resulting from overwriting some random memory after incorrect use of scanf) is bad. The code might work, in might not work, it might crash.

Read the manual and compile with all warnings on (-Wall -W -Wshadow etc.) to avoid similar errors in future.
by Krzysztof Duleba
Thu Oct 19, 2006 4:24 am
Forum: C++
Topic: set to vector C++
Replies: 3
Views: 7389

The compiler is faulty (upgrade to gcc if you can), the code is correct. You could try to play tricks with back_inserter, but it will probably give a similar error.
by Krzysztof Duleba
Tue Oct 17, 2006 1:07 pm
Forum: C++
Topic: Is a class implicitly a friend class of itself?
Replies: 5
Views: 2833

If you think about it, only class level access restrictions can be enforced by a compiler: // warning: not tested class foo { public: int doit(const foo *f) const { return x + f->x; } private: int x; }; int main() { foo *f1 = new foo; foo *f2 = new foo; if (rand() % 2 == 0) { f2 = f1; } f1->doit(f2)...
by Krzysztof Duleba
Tue Oct 17, 2006 3:24 am
Forum: Volume 107 (10700-10799)
Topic: 10753 - Exponential Function
Replies: 11
Views: 5225

I used BigInts. I don't think you can achieve required accuracy without some kind of arbitrary precision arithmetics.
by Krzysztof Duleba
Tue Oct 17, 2006 3:20 am
Forum: C++
Topic: Is a class implicitly a friend class of itself?
Replies: 5
Views: 2833

In C++ public/private/protected access restrictions work on class level, not on variable level. A class always has full access to all its members.
by Krzysztof Duleba
Tue Oct 17, 2006 3:17 am
Forum: C++
Topic: set to vector C++
Replies: 3
Views: 7389

This should work. What error message do you see?
by Krzysztof Duleba
Tue Sep 26, 2006 2:18 am
Forum: C++
Topic: ANSI C++ Manual
Replies: 5
Views: 3271

I usually just print out a lot of debbuging info or use gdb as the last resort (or to find quickly the reason of a segfault). If you don't like this style, try insight or ddd, they might suit you better.
by Krzysztof Duleba
Wed Sep 20, 2006 11:28 pm
Forum: Bugs and suggestions
Topic: CAPTCHA: To catch board miscreants
Replies: 4
Views: 2173

I think that using a CAPTCHA during registration is a good idea. There is a module you can simply plug in to phpbb. However, I'd really hate to be disturbed everytime I want to log in.

BTW: what makes you think that margaretkokgsmash did everything manually?
by Krzysztof Duleba
Fri Sep 08, 2006 12:07 pm
Forum: C++
Topic: STL >> string >> the [] operator to find the n't
Replies: 3
Views: 1848

Ouch, I thought you were pushing back to a string (which shouldn't work, so I didn't even bother to compile that code), but now I see you called push_back on a vector, which is perfectly valid.

I'm glad you were able to resolve it on your own.
by Krzysztof Duleba
Fri Sep 08, 2006 3:02 am
Forum: C++
Topic: STL >> string >> the [] operator to find the n't
Replies: 3
Views: 1848

Hint: learn how to read compiler messages, this one should be fairly straightforward.

Hint 2: does that reference say anything about push_back method?
by Krzysztof Duleba
Sat Sep 02, 2006 11:28 am
Forum: C++
Topic: are the time limits set so that STL code runs within it?
Replies: 12
Views: 4483

I agree, but programming contests are somewhat different - it's speed (both running time and coding time) that matters, not readability or reusability. And when a site compiles without optimization, well, STL structures simply get painfully slow (just think about all the functions that don't get inl...
by Krzysztof Duleba
Sat Sep 02, 2006 9:22 am
Forum: C++
Topic: are the time limits set so that STL code runs within it?
Replies: 12
Views: 4483

OJ has a strict time limit of 10s for all problems. Problemsetters either make inputs big enough to fit into it, or ignore it whatsoever in problems where time doesn't really matter. Contest hosting service allows to specify a time limit on a per problem basis and many problemsetters do use it. If y...
by Krzysztof Duleba
Sat Sep 02, 2006 8:50 am
Forum: C++
Topic: Compile error with comparer function
Replies: 6
Views: 3142

Oh, that's right. operator- should use const references, other operators too. And most of the time they should be const as well, to promise not to modify the objects they are operating on (as in bool operator-(const point &p)const{...} - note the second const that applies to the implied argument). B...
by Krzysztof Duleba
Sat Sep 02, 2006 7:51 am
Forum: C++
Topic: Compile error with comparer function
Replies: 6
Views: 3142

The use of reference in cross product is still incorrect - you're not changing p0 inside cross_product, are you? Also in most cases functions like sq_distance and cross_product should pass their arguments by const references instead of values (the only exceptions are primitive types and very small c...
by Krzysztof Duleba
Sat Sep 02, 2006 1:30 am
Forum: C++
Topic: Compile error with comparer function
Replies: 6
Views: 3142

The compiler is telling you everything, just read the error message and fix the code.

Hint: why are you using references when you should be using const-references? In particular using references in comp breaks the interface of comparators.

Go to advanced search