[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

C++ help?

Zach Dennis

11/24/2004 5:08:00 PM

I'm not a huge c++ guy, and I'm trying to help w/wxRuby development and
I've ran into an error. perhaps someone with more c++ knowledge can help
me out.

There is a classs wxPrintout in the the wxWindows library, I am trying
to wrap it for use in WxRuby. Whenever I try to create it

new wxPrintout()

it says I cannot instantiate the abstract class due to the following
members. Then it gives me the method signautre for a pure virtual method
OnPrintPage.

So I override wxPrintout in my file:

class wxPrintout{
public:
virtual bool OnPrintPage( int page )
}

Then it errors out because of a "class type redefinition". Any ideas how
to get around class type redefinition?

Thanks,

Zach


3 Answers

Wayne Vucenic

11/24/2004 5:37:00 PM

0

Hi Zach,

Since OnPrintPage is a pure virtual method in wxPrintout, you need to
derive a class from wxPrintout, and define OnPrintPage in that class.
Something like:

class wxPrintoutWrap : public wxPrintout
{
bool OnPrintPage( int page );
};

bool wxPrintoutWrap::OnPrintPage( int page )
{
// your code goes here

return true;
}

Hope this helps,

Wayne


On Thu, 25 Nov 2004 02:07:47 +0900, Zach Dennis <zdennis@mktec.com> wrote:
> I'm not a huge c++ guy, and I'm trying to help w/wxRuby development and
> I've ran into an error. perhaps someone with more c++ knowledge can help
> me out.
>
> There is a classs wxPrintout in the the wxWindows library, I am trying
> to wrap it for use in WxRuby. Whenever I try to create it
>
> new wxPrintout()
>
> it says I cannot instantiate the abstract class due to the following
> members. Then it gives me the method signautre for a pure virtual method
> OnPrintPage.
>
> So I override wxPrintout in my file:
>
> class wxPrintout{
> public:
> virtual bool OnPrintPage( int page )
> }
>
> Then it errors out because of a "class type redefinition". Any ideas how
> to get around class type redefinition?
>
> Thanks,
>
> Zach
>
>


Dave Burt

11/24/2004 8:35:00 PM

0


"Zach Dennis" <zdennis@mktec.com> wrote:
> new wxPrintout()
>
> it says I cannot instantiate the abstract class due to the following
> members. Then it gives me the method signautre for a pure virtual method
> OnPrintPage.
>
> So I override wxPrintout in my file:
>
> class wxPrintout{
> public:
> virtual bool OnPrintPage( int page )
> }
>
> Then it errors out because of a "class type redefinition".

You can redefine classes (heck, even individual objects) in Ruby, but not in
C++.
If you want a wxPrintout that is instantiable, you will need to define a
concrete subclass of wxPrintout:

class wxRubyPrintout : public wxPrintout
{
bool OnPrintPage( int page );
};


Zach Dennis

11/25/2004 4:17:00 AM

0

Wayne Vucenic wrote:
> Hi Zach,
>
> Since OnPrintPage is a pure virtual method in wxPrintout, you need to
> derive a class from wxPrintout, and define OnPrintPage in that class.
> Something like:
>
> class wxPrintoutWrap : public wxPrintout
> {
> bool OnPrintPage( int page );
> };
>
> bool wxPrintoutWrap::OnPrintPage( int page )
> {
> // your code goes here
>
> return true;
> }
>

Thank you very much Wayne, this is exaclty what I need to see for
something to click in my head.

Zach