C++ Classes

Discussion in 'Programming' started by seogoat, Oct 8, 2008.

  1. #1
    I am having problems understanding the purpose of classes.

    Is it this. If I had a football game, I would create a class for footballer, then derive multiple footballers from that class, rather than spending ages writing the same code over and over again?

    Does someone have an easy explanation that I can find easier to understand? I have been following the tutorials on www dot cprogramming dot com and they can be exhaustive.
     
    seogoat, Oct 8, 2008 IP
  2. seogoat

    seogoat Member

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    *****************bump****************************
     
    seogoat, Oct 9, 2008 IP
  3. qprojects

    qprojects Peon

    Messages:
    1,901
    Likes Received:
    103
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can create a class "Footballer" and create objects of it to create multiple footballers without the need of duplicating code.
    Let me know if it's still unclear :)
     
    qprojects, Oct 9, 2008 IP
    it career likes this.
  4. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #4
    As qprojects said create a Footballer class , create an array of Foolballer instance
    like Footballer * allFootballer = new Footballer[15] ;
     
    it career, Oct 11, 2008 IP
  5. leska

    leska Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #5
    I think that it will be helpful to read more tutorials about OOP in general not only in C++.
     
    leska, Oct 11, 2008 IP