faqts : Computers : Programming : Languages : C++

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

45 of 76 people (59%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

What is a Class ?

Sep 26th, 2003 14:59
Knud van Eeden, Andrew Parry, Bhushan Dongare,


General:
========
A class is NOT an object!

Class Definition:
=================
A class is the declaration of a specific data structure and any 
methods 
that operate on that data.  For example, the following is a class...

CMyClass
{
  public:
    void setValue(int iValue) { m_iValue = iValue; }
    int getValue() const { return m_iValue; }

  protected;
    int m_iValue;
};


Object Definition:
==================
An object is an instance of a class.

CMyClass firstInst, secondInst;

Both firstInst and secondInst are objects - they are instances of the 
class CMyClass.

---

see also:
C++: Class: Create: Simple: How to create a class in C++?
http://www.faqts.com/knowledge_base/view.phtml/aid/24828/fid/163