twoeyedhuman1111 wrote:
>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::ostringstream. (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.
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!