Tuesday, 2 April 2013

Week seven day 1

So far this week I have been working on classes and how they can be used to further shorten the coding process. Using classes is very useful if you are making many things that will need to use the same functions, using a class makes it so you can use any amount of function names as you wish keeping them under the same roof instead of making all new functions when you make a new name. 
for example:

class Cat
{
    public:
       int itsAge;
       int itsWeight;
};

Cat Frisky;
Frisky.itsAge = 10;
Frisky.itsWeight = 100;

Cat Billie;
Billie.itsAge = 2;
Billie.itsWeight = 50;

This is used as you can see to help make it shorter to have all this code instead of writing out all the ints for each 'Cat'.

No comments:

Post a Comment