Re: C++ class pointer (??) problem.
From: Thomi Richards (thomi_at_thomi.imail.net.nz)
Date: 02/28/05
- Next message: Jack Klein: "Re: How protect source code in template library?"
- Previous message: Nikki Locke: "Available C++ Libraries FAQ"
- In reply to: Rolf Magnus: "Re: C++ class pointer (??) problem."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Feb 2005 22:34:04 -0800
Rolf Magnus <ramagnus@t-online.de> wrote in message news:<cvptbc$52e$02$1@news.t-online.com>...
> >
> > I'm trying to do something very similar in C++ - I have a number of
> > classes all derived from a pure abstract class. I wantto be able to
> > pass those classes (not instances of the classes, the classes
> > themselves) to a function, and have that function create an instance
> > of the class, and manipulate it as need be.
>
> Why don't you want to pass an instance? In C++, a class cannot be a function
> parameter. In python, everything is an object. Even a class is just an
> instance in python. Therefore, you can pass it as argument to a function.
>
I'm constructing a Model / Control / View structure - THe model is an
internal class that should never be interfaced with directly. The
control is already constructed, and should be the main (read: only)
entry point into the system. THe idea is that third party programmers
can create their own "view" classes, and pass them to the control,
which will sort out their construction, and bind them to the model.
>
> > Another way to do this would be using a template function for the
> > builder function. One problem with this approach is thatthe builder
> > function will be called multiple times with different classes; using a
> > template function would waste code space, whereas a class-pointer (or
> > something similar) would probably be more compact.
>
> Then you would need something like a class object. I'd say templates would
> still be a lot more compact. Anyway, are you saying that out of experience
> or are you just speculating?
>
I'm speculating. Do you think that templatesa re the way to go?
- Next message: Jack Klein: "Re: How protect source code in template library?"
- Previous message: Nikki Locke: "Available C++ Libraries FAQ"
- In reply to: Rolf Magnus: "Re: C++ class pointer (??) problem."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]