delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/08/14:31:14

From: Vik Heyndrickx <Vik DOT Heyndrickx AT rug DOT ac DOT be>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Return Types for Constructors
Date: Mon, 08 Dec 1997 08:46:26 +0100
Organization: University of Ghent, Belgium
Lines: 25
Message-ID: <348BA5D2.503C@rug.ac.be>
References: <01bd0366$cfe6d140$d744e4cf AT cadvision DOT com>
NNTP-Posting-Host: eduserv1.rug.ac.be
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Robert Lazorko wrote:
> 
> I am writing code which implements classes for C++, and yet, the compiler
> gives the error message "return type specified for constructor invalid"...
> 
> Vector::Vector()
> {
>         x = 0;
>         y = 0;
> }

constructors always return void, so you should have written instead:

void Vector::Vector ()

IIRC the compiler assumes 'int' for the return type if you omit it in
C++.

BTW since this question is not DJGPP specific you should have posted
this to comp.lang.c++.

-- 
 \ Vik /-_-_-_-_-_-_/   
  \___/ Heyndrickx /          
   \ /-_-_-_-_-_-_/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019