HAY FAGGIT, LEARN C
[spoiler[HAY FAGGIT, LEARN C[/spoiler] HAY FAGGIT, LEARN C
[spoiler[HAY FAGGIT, LEARN C[/spoiler] HAY FAGGIT, LEARN C
[spoiler[HAY FAGGIT, LEARN C[/spoiler] HAY FAGGIT, LEARN C
[spoiler[HAY FAGGIT, LEARN C[/spoiler] HAY FAGGIT, LEARN C
[spoiler[HAY FAGGIT, LEARN C[/spoiler] HAY FAGGIT, LEARN C
[spoiler[HAY FAGGIT, LEARN C[/spoiler] HAY FAGGIT, LEARN C
[spoiler[HAY FAGGIT, LEARN C[/spoiler]
If you use C++, use STL, don't reinvent the wheel.
For example, use vector if you require fast random access, or lists if you require fast insertions.
For example, vector.
vector<int> numbers; // create vector with element type int
numbers.reserve(10); // reserve memory for 10 elements, optional
for (int i = 0; i < 10; i++)
numbers[i] = i; // or push_back(i)
Name:
Anonymous2009-01-20 11:49
>>7
As a note, reserve is NOT optional if you use the [] operator to add elements, it's only optional if you use push_back(), because push_back() automatically reserves more space.
Although it's more efficient to reserve space for 10 elements and then use push_back to add the numbers.
ISO-C++ prohibits declaration of "numbers" without a type.
Expected ";" before "." token.
Yes, I included <vector>.
Name:
Anonymous2009-01-20 13:11
Never mind, I alredy got it.
Now just a convention question. Should I make seperate .cpp files for seperate classes? Until now I've only done stuff with 2 classes, I just wrote it down in one cpp file. Should I create own cpp files for every class, like in Java or is it okay to leave it like that?
Name:
Anonymous2009-01-20 13:29
>>11
up to you. But if you've got loads, then it's best to start factoring things up.
Name:
Anonymous2009-01-20 13:59
>>9
Show me the sepples way then. I want to have an array with elements {12, 23, 43, 4, 15, 61, 79, 18, 9, 5};
Name:
Anonymous2009-01-20 14:08
>>8
Actually when you use the [] operator to add elements you need to call resize. In >>7 after he calls reserve the size of the vector is still zero, so you can't use the [] operator. It's better to use push_back when you want to add elements to a vector.
Historically, languages designed for other people to use have been bad: Cobol, PL/I, Pascal, Ada, C++. The good languages have been those that were designed for their own creators: C, Perl, Smalltalk, Lisp
>>21
Didn't Bjarne design Sepples for himself? Lisp was designed for no one to use, and once they realized people wanted it, they never planned for people to use sexps. I'm pretty sure Alan Kay mostly wanted other people to use Smalltalk, since he wasn't the hugest of programmers himself.
Name:
Anonymous2009-01-20 16:13
>>22
I lol and :( everytime someone posts that pic
Name:
Anonymous2009-01-20 16:13
hugest
Name:
Anonymous2009-01-20 16:16
>>23
Alan Kay designed Smallkalk to be used by kids.
Name:
Anonymous2009-01-20 16:18
>>26
Kids designed Smalltalk to be used by Alan Kay.
C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it. Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C.
In other words: the choice of C is the only sane choice. I know Miles
Bader jokingly said "to piss you off", but it's actually true. I've come
to the conclusion that any programmer that would prefer the project to be
in C++ over C is likely a programmer that I really *would* prefer to piss
off, so that he doesn't come and screw up any project I'm involved with.
C++ leads to really really bad design choices. You invariably start using
the "nice" library features of the language like STL and Boost and other
total and utter crap, that may "help" you program, but causes:
- infinite amounts of pain when they don't work (and anybody who tells me
that STL and especially Boost are stable and portable is just so full
of BS that it's not even funny)
- inefficient abstracted programming models where two years down the road
you notice that some abstraction wasn't very efficient, but now all
your code depends on all the nice object models around it, and you
cannot fix it without rewriting your app.
In other words, the only way to do good, efficient, and system-level and
portable C++ ends up to limit yourself to all the things that are
basically available in C. And limiting your project to C means that people
don't screw that up, and also means that you get a lot of programmers that
do actually understand low-level issues and don't screw things up with any
idiotic "object model" crap.
So I'm sorry, but for something like git, where efficiency was a primary
objective, the "advantages" of C++ is just a huge mistake. The fact that
we also piss off people who cannot see that is just a big additional
advantage.
If you want a VCS that is written in C++, go play with Monotone. Really.
They use a "real database". They use "nice object-oriented libraries".
They use "nice C++ abstractions". And quite frankly, as a result of all
these design decisions that sound so appealing to some CS people, the end
result is a horrible and unmaintainable mess.
But I'm sure you'd like it more than git.
Name:
Anonymous2009-01-21 4:09
>>1
Indent your code first if you want us to help you. CORRECT SOURCE AND RESUBNIT