|
-
Feb 28th, 2002, 08:58 PM
#1
Thread Starter
New Member
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
-
Mar 1st, 2002, 11:28 AM
#2
Frenzied Member
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 Value1, int Value2);
void Subtact(int Value, int 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

-
Mar 1st, 2002, 01:27 PM
#3
transcendental analytic
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|