Results 1 to 3 of 3

Thread: Classes

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Posts
    4

    Classes

    Can someone please explain to me what classes do, and when to use them. I very new to C++, and I'm a little confused on what they do.

    Thanks,

    Kenneth Devorak
    Get paid to host your website with NO ADS.

    http://www.talknet.cc

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Classess are generally groups of functions and/or VARs. Its generally up to the programmer when to use or not use them. Here is a quick simple example

    PHP Code:
    class CMath     //Name of your class
    {
    public:
      
    int total;       //Public VAR in your class
      
      
    CMath();      
      ~
    CMath();

      
    void Add(int Value1int Value2);
      
    void Subtact(int Valueint Value2);
    };

    CMath::CMath()
    {
    }

    CMath::~CMath()
    {
    }

    void CMath::Add(int Value);
    {
      
    total total value;
    }

    void CMath::Add(int Value);
    {
      
    total total value;
    }

    int Main()
    {
      
    CMath math;           //When this is done CMath::CMath() is called
      
    math.Add(1);           //When this is done CMath::Add(int Value) is called
      
    math.Subtract(5);   //When this is done CMath::Add(int Value) is called
      
    cout << math.total;//When this is done total in CMath is called
    }   //When this is done void CMath::~CMath() is called because the VAR is being destroyed 
    I wrote this all by hand so there maybe some minor mistakes in my example
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You should read a tutorial, I recommend TYC++:
    http://newdata.box.sk/bx/c/
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width