🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #915

IS THIS LEGAL? Static method returns pointer to class

#915
From: Arthur Cinader Jr
Date: Mon, 04 Mar 1996 05:14
40 lines
1505 bytes
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
Technical Details
Message-ID: <4hdu70$efa@panix.com>
Path: arc1-ca.pugleaf.net!newsfeed.internetmci.com!panix!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsfeed.internetmci.com!panix!not-for-mail
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>
NNTP-Posting-Host: panix.com