LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   constructor return type (https://www.linuxquestions.org/questions/programming-9/constructor-return-type-115006/)

macro-linux 11-11-2003 07:28 PM

constructor return type
 
I programming a code
example:
Code:

class MyWidget: public QWidget
{
public:
      MyWidget( QWidget *parent = 0, const  char *name =0)
};

MyWidget::MyWidget( QWidget *parent, const char *name)
              :QWidget( parent, name)
{
¡_¡_¡_¡_¡_¡_¡_¡_¡_¡_¡_¡_¡_¡_
¡_¡_¡_¡_¡_¡_¡_¡_¡_¡_¡_¡_
}

the compiler tell me that the
" ISO C++ forbids defining types within return Type
return type specification for constructor invalid"
but have some code, can pass the compile
why?
I know the construction don't need the return type!

wapcaplet 11-11-2003 08:45 PM

It looks like maybe you forgot a semicolon after the declaration of MyWidget(). Also, perhaps you need a forward declaration for MyWidget, since you are trying to declare a pointer to one before it's fully defined. I think all you need to do is put:

Code:

class MyWidget;
before you start declaring your class.

macro-linux 11-12-2003 01:29 AM

thank you
the reason is the semicolor!


All times are GMT -5. The time now is 01:51 PM.