Article View: gnu.g++.help
Article #916Re: IS THIS LEGAL? Static method returns pointer to class
From: Noel Fegan
Date: Mon, 04 Mar 1996 11:10
Date: Mon, 04 Mar 1996 11:10
62 lines
2195 bytes
2195 bytes
acinader@panix.com (Arthur Cinader Jr) wrote:
>I may be going at this wrong, but I want to have a class
>Triangle contain a static method called makeinstance. The
>method will be passed a refernce to a Param object that has
>a list of parameters for checking first and then passing to
>the Triangle constructor.
>The parameters are checked and if all is ok, a Triangle
>instance is "newed" and the pointer to the new Trinagle is
>returned. When I compile, I get the following error:
>% g++ -c triangle.C
>In file included from triangle.C:8:
>triangle.h:17: syntax error before `*'
>...
>%
>***The declaration for the class:
> 1 // triangle.h
> 2 // declaration of class Triangle extends shape
> 3
> 4 #ifndef TRIANGLE_H
> 5 #define TRIANGLE_H
> 6
> 7 #include "point.h"
> 8 #include "param.h"
> 9
> 10 class Trianlge : public Point {
> 11 public:
> 12 Trinagle(float = 0.0, float = 0.0, float = 0.0);
> 13 float gets() const;
> 14 virtual void draw() const;
> 15
> 16 static Param &getParams();
> 17 static Triangle *makeinstance(Param &);
> 18 private:
> 19 float side;
> 20 };
> 21
> 22 #endif
The idea looks fine to me. However, if this is a direct copy of the code you
wrote you better mind your spelling. The word Triangle is spelled differently in
the three place it appears:
class Trianlge...
Trinagle(float....
static Triangle *makeinstance...
This would definitely cause the problem you described...
--
Noel Fegan
European Software Development Department
American Power Conversion
My views used to be my own, and then I got married...
I don't speak for APC...
nfegan@apcc.com
Technical Details
Message-ID:
<4hej4b$ou1@apccorp.apcc.com>Path:
arc1-ca.pugleaf.net!apccorp.apcc.com!rootReferences:
<4hdu70$efa@panix.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!apccorp.apcc.com!root From: nfegan@apcc.com (Noel Fegan) Newsgroups: gnu.g++.help,comp.lang.c++ Subject: Re: IS THIS LEGAL? Static method returns pointer to class Date: Mon, 04 Mar 1996 11:10:21 GMT Organization: American Power Conversion Message-ID: <4hej4b$ou1@apccorp.apcc.com> References: <4hdu70$efa@panix.com> NNTP-Posting-Host: hewie.galway.apcc.com X-Newsreader: Forte Free Agent 1.0.82