LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-11-2003, 07:28 PM   #1
macro-linux
LQ Newbie
 
Registered: Sep 2003
Posts: 25

Rep: Reputation: 15
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!
 
Old 11-11-2003, 08:45 PM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
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.
 
Old 11-12-2003, 01:29 AM   #3
macro-linux
LQ Newbie
 
Registered: Sep 2003
Posts: 25

Original Poster
Rep: Reputation: 15
thank you
the reason is the semicolor!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
not calling copy constructor on function return jhorvath Programming 7 09-22-2009 12:43 PM
C++ return type ashirazi Programming 4 09-19-2004 03:01 PM
strange C++ constructor error imm102 Programming 6 02-21-2004 04:33 PM
Copy constructor in C++ prenayan Linux - General 3 11-13-2003 02:48 PM
c++ constructor question jhorvath Programming 6 11-06-2003 10:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration