Good software using c++ for learning how c++ works

T

twoeyedhuman1111

I was wondering if anybody knew any open source software which has
source code that is well documented and written in c++ that I could use
to learn from.

I want to learn more about how programs are built and I thought one
good way is by example.
 
P

Phlip

twoeyedhuman1111 said:
I was wondering if anybody knew any open source software which has
source code that is well documented and written in c++ that I could use
to learn from.

I want to learn more about how programs are built and I thought one
good way is by example.

This sample is short on documentation, but it is then exemplary C++ style:

http://sourceforge.net/projects/unittest-cpp/

Download it, build it, and run it. Then read the folder src/tests. You will
find samples like this:

TEST(ArrayCloseSucceeds)
{
float const a1[] = {1, 2, 3};
float const a2[] = {1, 2.01f, 3};
CHECK_ARRAY_CLOSE (a1, a2, 3, 0.1f);
}

That's a unit test case that documents part of the UnitTest++ project. It
shows how CHECK_ARRAY_CLOSE() works.

There are those who claim that unit tests are the best documentation. Your
college professor has doubtless told you this.

Here's a slightly more complex test:

TEST (StreamingMultipleTimesConcatenatesResult)
{
MemoryOutStream stream;
stream << "Bork" << "Foo" << "Bar";
CHECK_EQUAL ("BorkFooBar", stream.GetText());
}

It shows that MemoryOutStream behaves like std::eek:stringstream. (On some
platforms, they will indeed be the same class.)

Studying this code will show you how a balanced C++ program can distribute
its behavior into minimal and useful classes.
 
Y

Yogesh

twoeyedhuman1111 said:
I was wondering if anybody knew any open source software which has
source code that is well documented and written in c++ that I could use
to learn from.

I want to learn more about how programs are built and I thought one
good way is by example.
I would say take a look at JUCE.
www.rawmaterialsoftware.com/juce
Its Cross-platform and uses nearly all the design patterns, I know.
 
F

Frederick Gotham

Phlip posted:
There are those who claim that unit tests are the best documentation.
Your college professor has doubtless told you this.


I find that the self-taught programmers are far more proficient than the
college students -- probably because they took up programming as a hobby long
before they ever attended college.
 
T

twoeyedhuman1111

Frederick said:
Phlip posted:



I find that the self-taught programmers are far more proficient than the
college students -- probably because they took up programming as a hobby long
before they ever attended college.

Actually, I started trying to teach myself programming in 6th grade and
found it very fun but very difficult. I have tried to make some
different programs which eventually outgrew themselves and became too
complicated for me.

It seems though that there are many programs which I can learn from.
I'm going to read these and then attempt to create another program.
Also, next time, I think I'm going to have to think harder about how
OOP and how I could better use it.

Thank you for showing me Juce, I'll read up on this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top