|
From: <Mat...@Ve...> - 2005-05-31 16:20:43
|
Well my advice to you would be to start with the simplest possible code, and
then work up to the complicated version. Also, when working with classes, it
helps to draw some kind of simple paper diagram. At my desk, I have posted
the diagrams of the <ios> hierarchy and the <stdexcept> hierarchy for
example.
Here would be some really trivial multi-class code. Note how you can catch a
runtime_error as an exception because runtime_error is based on exception.
If you look at the stdexcept system header or the docs for this header, you
can see how this works in more detail.
Also, google "C++ polymorphism" as well.
HTH!
Matt
#include <stdexcept>
#include <iostream>
using namespace std;
int main(int argc, char* argv)
{
try
{
throw runtime_error("foo");
}
catch (const exception& e)
{
cout << e.what();
return 1;
}
return 0;
}
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of Sabree
Blackmon
Sent: Friday, May 27, 2005 5:52 PM
To: Dev-C++ Mailing List
Subject: [Dev-C++] Base classes....
Hello all,
I am making a plugin manager that loads dll's and stores pointers to the
imported classes in vector so users can request the classes when ever during
the program. However the problem lies in the fact that vectors or arrays can
only store one type of object in other words one type of class pointer which
will not work. I know that a base class pointer is compatible with a derived
class. I was thinking about creating a base class where all plugin classes
are derived from. I know this is possible because Crystal Space 3d uses the
same technique. I'm just not sure how. I've included the file where the base
class in Crystal Space is declared. Maybe someone can make some sense of it
all. I tried to reduce the file size, so if anyone need the rest just say
so. Thanks.
___________________________________________________________________
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. Thank you.
|