Boost logo

Boost Users :

From: Travis Savo (tsavo_at_[hidden])
Date: 2008-02-10 19:12:28


I thought that was expected behavior when you didn't declare factory virtual
in B, since the virtual jump table in A is overriding B's function table.

When I tried this, making B's factory virtual caused B's factory to get
called instead of A's.

On Feb 10, 2008 3:55 PM, Frank Mori Hess <fmhess_at_[hidden]> wrote:

> On Sunday 10 February 2008 09:55, Paul J R wrote:
> > class A {
> > public:
> > A() {}
> > ~A() {}
> > virtual void worker() {
> > std::cout << "I am A worker" << std::endl;
> > }
> > virtual A *factory() {
> > std::cout << "Factory for A class called" << std::endl;
> > return new A;
> > }
> > virtual void operator()() {
> > std::cout << "Calling A operator()" << std::endl;
> > worker();
> > }
> > void threadcontroller() {
> > boost::thread_group thre;
> > for(;;) {
> > std::cout << "I am in the A.threadcontroller()
> > method" << std::endl;
> > A *mea = factory();
>
> I think you might need to call factory like "this->factory()"
>
> > the next 2 are from after the thread_group.create_thread() call. Once
> > its in the thread it seems to revert to class A's methods.
> >
> > Now, i know if i overload the threadcontroller class in B it'd solve all
> > my problems, but the real threadcontroller method is alot more complex
> > and class A has about 6 sub classes so replicating the threadcontroller
> > in each of the classes would be a little tedious.
>
> --
> Frank
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
-Travis Savo
CEO, Verse Studios
web: http://www.verse-studios.com
email: tsavo_at_[hidden]
phone: 818.574.5009
blog: http://inverse.verse-studios.com
linkedin: http://www.linkedin.com/in/travissavo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net