Article View: gnu.g++.help
Article #921Re: IS THIS LEGAL? Static method returns pointer to class
From: CHAMBERS Jason
Date: Tue, 05 Mar 1996 19:44
Date: Tue, 05 Mar 1996 19:44
61 lines
2484 bytes
2484 bytes
This is a multi-part message in MIME format.
---------------------------------19997724768799091920253434
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
At line 10, surely Trianlge should be Triangle?
---------------------------------19997724768799091920253434
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
From: acinader@panix.com (Arthur Cinader Jr)
Newsgroups: gnu.g++.help,comp.lang.c++
Subject: IS THIS LEGAL? Static method returns pointer to class
Date: 4 Mar 1996 00:14:08 -0500
Organization: Panix
Message-ID: <4hdu70$efa@panix.com>
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
---------------------------------19997724768799091920253434--
Technical Details
Message-ID:
<Dnt85t.FGu@doc.ntu.ac.uk>Path:
arc1-ca.pugleaf.net!tank.news.pipex.net!pipex!warwick!nott-cs!trent-doc!newsReferences:
<4hdu70$efa@panix.com>Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.help,comp.lang.c++ Path: arc1-ca.pugleaf.net!tank.news.pipex.net!pipex!warwick!nott-cs!trent-doc!news From: CHAMBERS Jason <pt3chaj> Subject: Re: IS THIS LEGAL? Static method returns pointer to class X-Nntp-Posting-Host: pup21 Content-Type: multipart/mixed; boundary="-------------------------------19997724768799091920253434" Message-ID: <Dnt85t.FGu@doc.ntu.ac.uk> Sender: news@doc.ntu.ac.uk Organization: The Nottingham Trent University, DOC. References: <4hdu70$efa@panix.com> Mime-Version: 1.0 Date: Tue, 5 Mar 1996 19:44:17 GMT X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.2 sun4c) X-Url: news:4hdu70$efa@panix.com