Saturday, December 5, 2009


Well, I was a bit caught up with some last minute homework last week, so I haven't posted in a couple days. Tsk Tsk.

So what I went over today, was the Classes and Classes II page, at both of these links:

I gained an understanding of why classes are useful, and I also found out that they are almost exactly the same as structures, except that the default access of the members of a class is private juxtapose to public.

It was a lot of reading, and some tinkering, to understand both of these pages pretty well. I haven't created any code with the knowledge gained from these two pages, except for just some small modifications to make sure I understood what I was reading. Here is an example: I wrote a small circle class, and then printed the area of my circle:

#include <cstdlib>
#include <iostream>
using namespace std;

class CCircle {
    float x;
    void set_values (float);
    float area () {return (x*3.14159265*x);}

void CCircle::set_values (float a) {
    x = a;

int main () {
    CCircle circ, circb, circc;
    circ.set_values (3);
    circb.set_values (5);
    circc.set_values (7);
    cout << "circ area: " << circ.area() << endl;
    cout << "circb area: " << circb.area() << endl;
    cout << "circc area: " << circc.area() << endl;
    return EXIT_SUCCESS;

I plan to go over the next two pages in this tutorial, which are on friendship//inheritance, and polymorphism. Hopefully, I can read through those, and create some small programs like the one I made today. So tomorrow, I will create another small program using a class, and I will also use pointers and dynamic memory to do so. After this, I will read those next to article pages. I also have quite a bit of homework to do tomorrow, so we'll see how far I get.

Lately the articles and blogs on both gamasutra and have been a bit bland, so sadly, I have no interesting articles for anyone to read this time :P

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.