Topic: Explicit call of constructor
Author: Paul Petrucelly <prp9071@halcyon.com>
Date: 1996/04/24 Raw View
I just saw a piece of code where a constructor was explicitly called from another
constructor ie:
foo{
public:
foo( int data )
{
some code....
foo( some char parm );
some code ...
}
foo( char parm )
{
some code ...
}
};
My gut feeling was that this is illegal, but after looking around,
I found that the C++ Programming language states that member functions
can be called from a construct (obviously)... and that constructors are
member functions ( r.12.1 ).
I'm looking for direction to a specific standard which states that this is
illegal (if it is).
If it is not illegal, then what are the implications, especially if foo is a
derived class, and the function uses initializes in the declaration ie
foo( int data ): baseclass( data ){};
thanks
paul
prp9071@halcyon.com
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl)
Date: 1996/04/24 Raw View
Hi,
Paul Petrucelly (prp9071@halcyon.com) wrote:
: I just saw a piece of code where a constructor was explicitly called from another
: constructor ie:
: foo{
class foo { // I guess (just nit picking...)
: public:
: foo( int data )
: {
: some code....
: foo( some char parm );
: some code ...
: }
: foo( char parm )
: {
: some code ...
: }
: };
: My gut feeling was that this is illegal, but after looking around,
: I found that the C++ Programming language states that member functions
: can be called from a construct (obviously)... and that constructors are
: member functions ( r.12.1 ).
The code above is not illegal but probably does something different
than is expected: the expression 'foo(some char parm)' creates a
temporary object of type 'foo'. It does not call the other constructor
for the same object. Since there is nothing else done to the temporary
object the whole behavior of this code are the side effects created by
the ctor 'foo(char)' or the dtor (which is no-existent in the code
above). This is hardly the intended behavior (if it is you might
consider to submit the code as a candidate to an obfuscated C++
contest...).
--
dietmar.kuehl@uni-konstanz.de
http://www.informatik.uni-konstanz.de/~kuehl/
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: kanze@gabi-soft.fr (J. Kanze)
Date: 1996/04/25 Raw View
In article <317D8D0D.754F@halcyon.com> Paul Petrucelly
<prp9071@halcyon.com> writes:
|> I just saw a piece of code where a constructor was explicitly called from
|> another constructor ie:
|> foo{
|> public:
|> foo( int data )
|> {
|> some code....
|> foo( some char parm );
|> some code ...
|> }
|> foo( char parm )
|> {
|> some code ...
|> }
|> };
|> My gut feeling was that this is illegal, but after looking around,
|> I found that the C++ Programming language states that member functions
|> can be called from a construct (obviously)... and that constructors are
|> member functions ( r.12.1 ).
|> I'm looking for direction to a specific standard which states that this is
|> illegal (if it is).
|> If it is not illegal, then what are the implications, especially if foo is
|> a derived class, and the function uses initializes in the declaration ie
|> foo( int data ): baseclass( data ){};
It's not illegal, it just doesn't do what many people seem to expect.
Explicitly calling a constructor from within a constructor does exactly
what explicitly calling a constructor anywhere else does: it constructs
an unnamed temporary of said type.
In the example that you give, this temporary is never used; in such
cases, it is conceivable that the constructor was only called for side
effects, but if so, this is really tricky programming, and there should
at least be a comment in the code as to what is going on. In most
cases, I would suspect an error, and I believe that some compilers may
even warn about this situation.
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: kanze@gabi-soft.fr (J. Kanze)
Date: 1996/04/26 Raw View
In article <KANZE.96Apr25121951@gabi.gabi-soft.fr> kanze@gabi-soft.fr
(J. Kanze) writes:
|> In article <317D8D0D.754F@halcyon.com> Paul Petrucelly
|> <prp9071@halcyon.com> writes:
|> |> I just saw a piece of code where a constructor was explicitly called from
|> |> another constructor ie:
|> |> foo{
|> |> public:
|> |> foo( int data )
|> |> {
|> |> some code....
|> |> foo( some char parm );
|> |> some code ...
|> |> }
|> |> foo( char parm )
|> |> {
|> |> some code ...
|> |> }
|> |> };
|> |> My gut feeling was that this is illegal, but after looking around,
|> |> I found that the C++ Programming language states that member functions
|> |> can be called from a construct (obviously)... and that constructors are
|> |> member functions ( r.12.1 ).
|> |> I'm looking for direction to a specific standard which states that this is
|> |> illegal (if it is).
|> |> If it is not illegal, then what are the implications, especially if foo is
|> |> a derived class, and the function uses initializes in the declaration ie
|> |> foo( int data ): baseclass( data ){};
|> It's not illegal, it just doesn't do what many people seem to expect.
|> Explicitly calling a constructor from within a constructor does exactly
|> what explicitly calling a constructor anywhere else does: it constructs
|> an unnamed temporary of said type.
|> In the example that you give, this temporary is never used; in such
|> cases, it is conceivable that the constructor was only called for side
|> effects, but if so, this is really tricky programming, and there should
|> at least be a comment in the code as to what is going on. In most
|> cases, I would suspect an error, and I believe that some compilers may
|> even warn about this situation.
As a follow-up, note that if the `some char param' in the `explicit
constructor call' is in fact just a single variable, as opposed to some
more complicated expression, then the statement in question is not an
`explicit constructor call', but a (possibly duplicate) declaration. If
the variable is in scope, the compiler should generate a duplicate
declaration error, and if `foo' has no default constructor, it should
generate an error because it cannot initialized the variable.
(It is only after the initial poster made a larger extract of his
problem available to me, and I discussed the issue with my compilers,
that I realized this.)
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: feb6399@osfmail.isc.rit.edu (Frank Barrus)
Date: 1996/04/29 Raw View
In article <KANZE.96Apr25121951@gabi.gabi-soft.fr>,
J. Kanze <kanze@gabi-soft.fr> wrote:
>In article <317D8D0D.754F@halcyon.com> Paul Petrucelly
><prp9071@halcyon.com> writes:
>
>|> I just saw a piece of code where a constructor was explicitly called from
>|> another constructor ie:
>
>|> foo{
>|> public:
>|> foo( int data )
>|> {
>|> some code....
>|> foo( some char parm );
>|> some code ...
>|> }
>
>|> foo( char parm )
>|> {
>|> some code ...
>|> }
>|> };
>
>It's not illegal, it just doesn't do what many people seem to expect.
>Explicitly calling a constructor from within a constructor does exactly
>what explicitly calling a constructor anywhere else does: it constructs
>an unnamed temporary of said type.
>
>In the example that you give, this temporary is never used; in such
>cases, it is conceivable that the constructor was only called for side
>effects, but if so, this is really tricky programming, and there should
>at least be a comment in the code as to what is going on. In most
>cases, I would suspect an error, and I believe that some compilers may
>even warn about this situation.
Okay, I just tested this to see how to get it to just call
the constructor code but not create a new object,
and oddly enough when I tried to just do:
foo( int data )
{
this->foo('X');
}
It said that foo was not a member of 'this',
however,
((foo*)this)->foo('X');
worked like a charm and gave me the desired results.
(putting printf("%x\n", (int)this); in each
of the constructor functions confirmed that they both
used the same object)
So, yes, you can call the constructor functions, but you have
to a be a bit tricky. Generally, it should probably be avoided.
If the code needs to be shared, perhaps a common member function
that performs the shared task can (and should) be created.
--
Frank "Shaggy" Barrus: feb6399@osfmail.isc.rit.edu, shaggy@csh.rit.edu
http://www.csh.rit.edu/~shaggy
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: JdeBP@jba.co.uk (Jonathan de Boyne Pollard)
Date: 1996/05/02 Raw View
Micha Berger (aishdas@haven.ios.com) wrote:
| Frank Barrus asked about:
| : ((foo*)this)->foo('X');
|
| Which we've established is invalid, as a constructor is not a member
| function, it just syntactically looks like one.
Ah, no. That's not what I said.
A constructor *is* a member function. It is a member function that has
no name.
What I was saying was that
foo('c')
is not a function call, syntactically. It's a creation of an unnamed
ovalue.
Whereas
((foo*)this)->foo('X');
is ill-formed, since there is no member named `foo' in the class `foo'.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: jason@cygnus.com (Jason Merrill)
Date: 1996/05/02 Raw View
>>>>> Jonathan de Boyne Pollard <JdeBP@jba.co.uk> writes:
> Whereas
> ((foo*)this)->foo('X');
> is ill-formed, since there is no member named `foo' in the class `foo'.
Ah, but there is. There is the implicit typedef of foo::foo to foo.
9 Classes [class]
2 A class-name is inserted into the scope in which it is declared imme-
diately after the class-name is seen. The class-name is also inserted
into the scope of the class itself. For purposes of access checking,
the inserted class name is treated as if it were a public member name.
A class-specifier is commonly referred to as a class definition.
Jason
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: JdeBP@jba.co.uk (Jonathan de Boyne Pollard)
Date: 1996/05/02 Raw View
Seeing
((foo*)this)->foo('X');
in this discussion has led me to thinking. Consider the following program.
#include <iostream.h>
class Base { public:
void Derived () { cout << "Hello there." << endl ; }
} ;
class Derived : public Base { public:
Derived() { cout << "Derived::Derived" << endl ; }
void f () ;
} ;
void Derived::f () { (*this).Derived() ; }
int
main ( int, char ** )
{
Derived d ;
d.f() ;
return 0 ;
}
Three different compilers produce three different results :
[C:\Develop\bugs]hc -Hldopt=/batch/nol name.cpp
MetaWare High C/C++ Compiler R2.8a
(c) Copyright 1987-95, MetaWare Incorporated
w "name.cpp",L12/C37(#726): Direct constructor call is not ANSI-conforming.
| Use `new(&object) Derived' instead.
No errors 1 warning
[C:\Develop\bugs]name
Derived::Derived
Derived::Derived
[C:\Develop\bugs]bcc name.cpp
Borland C++ Version 4.11 Copyright (c) 1993, 1994 Borland International
name.cpp:
Turbo Link Version 1.5 for OS/2 Copyright (c) 1994 Borland International
[C:\Develop\bugs]name
Derived::Derived
Hello there.
[C:\Develop\bugs]icc -Tl- name.cpp
IBM VisualAge C ++ for OS/2, Version 3
(C) Copyright IBM Corp. 1991, 1995.
- Licensed Materials - Program Property of IBM - All Rights Reserved.
name.cpp(7:24) : error EDC3303: "Base" cannot be a base of "Derived"
because "Base" contains a member function called "Derived".
name.cpp(12:37) : error EDC3193: Explicit call to constructor "::Derived"
is not allowed.
[C:\Develop\bugs]
The challenge : Which, if any, is correct ? Justify your choice with
reference to the DWP.
I'll start you off. Borland C++ looks right to me. The RHS of the '->'
operator is an id-expression, and name lookup for `Derived' should find the
function declaration in `Base' according to [class.member.lookup].
MetaWare High C++ is definitely wrong. The syntax couldn't possibly match
[expr.type.conv] since "(*this).Derived", according to [expr.ref 6], is a
non-lvalue expression which can only be used in a member function call
expression. [expr.type.conv] requires that "(*this).Derived" be a simple
type specifier, which it isn't.
IBM VisualAge C++ has probably the best approach, and the one that *should*
be correct. However, I cannot find a rule in the WP that supports this
diagnostic. AFAIAA, as the WP currently stands, this diagnostic is wrong.
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: shankar@xenon.chromatic.com (Shankar Unni)
Date: No Date Raw View
Rich Paul wrote:
>
> Frank Barrus wrote:
> > It said that foo was not a member of 'this',
> > however,
> > ((foo*)this)->foo('X');
> >
>
> Is this standard, correct, and portable?
Probably not.
However, there's a fairly guaranteed way to call the constructor explicitly on
the object:
new(this) Foo;
(where Foo is the class name) - i.e. using the placement new syntax.
I'll try to look up the legality of this construct, but it should work reasonably
well on most implementations (or at least, as expected - it will probably have
nasty consequences like leaking memory, etc).
--
Shankar Unni shankar@chromatic.com
Chromatic Research (408) 752-9488
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: jpotter@falcon.lhup.edu (John E. Potter)
Date: 1996/05/06 Raw View
Jonathan de Boyne Pollard (JdeBP@jba.co.uk) wrote:
: Three different compilers produce three different results :
More fodder.
$ g++ der.ctor.C # gcc2.7.2
$ a.out
Derived::Derived
Derived::Derived
$ CC der.ctor.C # cfront3.0.2
CC der.ctor.C:
cc -Wl,-L/usr/local/lib der.ctor.c -lC
$ a.out
Derived::Derived
Hello there.
$ xlC der.ctor.C # IBM
"der.ctor.C", line 7.28: 1540-303: (S) "Base" cannot be a base of
"Derived" because "Base" contains a member function called "Derived".
"der.ctor.C", line 12.41: 1540-193: (S) Explicit call to constructor
"::Derived" is not allowed.
John
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: Rich Paul <linguist@cyberspy.com>
Date: 1996/04/29 Raw View
Frank Barrus wrote:
> It said that foo was not a member of 'this',
> however,
> ((foo*)this)->foo('X');
>
Is this standard, correct, and portable?
If so, it'll save me some whining when I write
several constructors for a class ...
BUT ... what about initializers before the body?
and const objects ... my gut instinct is that they
should be ok, but I"m not sure if explicitly
calling the constructor this way would include them
or not ... if it does, it should break on const and
referance members ...
--
#include <legalbs/standarddisclaimer>
Rich Paul | If you like what I say,
tell my
C++, OOD, OOA, OOP, | employer, but if you
don't,
OOPs, I forgot one ... | don't blame them. ;->
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1996/04/30 Raw View
Rich Paul <linguist@cyberspy.com> writes:
>Frank Barrus wrote:
>> It said that foo was not a member of 'this',
>> however,
>> ((foo*)this)->foo('X');
>>
>
>Is this standard, correct, and portable?
No, it is none of the above.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: JdeBP@jba.co.uk (Jonathan de Boyne Pollard)
Date: 1996/04/30 Raw View
Frank Barrus (feb6399@osfmail.isc.rit.edu) wrote:
| In article <KANZE.96Apr25121951@gabi.gabi-soft.fr>,
| J. Kanze <kanze@gabi-soft.fr> wrote:
| >In article <317D8D0D.754F@halcyon.com> Paul Petrucelly
| ><prp9071@halcyon.com> writes:
| >|> foo::foo( int data )
| >|> {
| >|> some code....
| >|> foo( some char parm );
| >|> some code ...
| >|> }
| >
| >It's not illegal, it just doesn't do what many people seem to expect.
| >Explicitly calling a constructor from within a constructor does exactly
| >what explicitly calling a constructor anywhere else does: it constructs
| >an unnamed temporary of said type.
|
| Okay, I just tested this to see how to get it to just call
| the constructor code but not create a new object,
| and oddly enough when I tried to just do:
| foo( int data )
| {
| this->foo('X');
| }
|
| It said that foo was not a member of 'this',
And correctly so.
[class.ctor 1]
"1. Constructors do not have names. [...]"
There is no member named `foo' in your class foo, and you cannot
declare one. Any attempt to declare such a member is interpreted as
"A special declarator syntax using the class name" [class.ctor 1].
One of the main sources of confusion over this whole issue is, ironically,
due to the way that people attempt to explain what code such as yours does.
It is sad to say that most people's explanations start with
"Calling a constructor does not do X, it does ..."
Their error is in perpetuating the myth that this syntax in any way
corresponds to a member function call. It does not. The syntax covering
the above code can be found in the standard under "Postfix expressions",
in the clause "Explicit type conversion (functional notation)".
[expr.type.conv 1]
"1. A simple-type-specifier followed by a parenthesised
expression-list constructs a value of the specified type
[...]"
This is NOT a function call. Function calls are a wholly separate clause
(the immediately preceding one). The syntax here is for creating unnamed
ovalues. It just happens to *resemble* the syntax for function calls
(this is deliberate).
Referring to [expr.post 1] we find that the syntax for function calls is
postfix-expression ( expression-listopt )
whereas the syntax for constructing unnamed ovalues is
simple-type-specifier ( expression-listopt )
Clearly, however close the resemblance, as far as syntactical analysis goes
the two are distinct. Creation of an unnamed ovalue is NOT a function call.
| however,
| ((foo*)this)->foo('X');
| worked like a charm and gave me the desired results.
Your compiler's name lookup is broken. There is no member named `foo' in
the scope of your class. Constructors do not have names, remember.
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Alan Griffiths <aGriffiths@ma.ccngroup.com>
Date: 1996/05/01 Raw View
In article: <4m4qoe$2ru@silver.jba.co.uk> JdeBP@jba.co.uk (Jonathan de
Boyne Pollard) writes:
>
> Frank Barrus (feb6399@osfmail.isc.rit.edu) wrote:
> | In article <KANZE.96Apr25121951@gabi.gabi-soft.fr>,
> | J. Kanze <kanze@gabi-soft.fr> wrote:
> | [snip]
> | > | Okay, I just tested this to see how to get it to just call
> | the constructor code but not create a new object,
> | and oddly enough when I tried to just do:
> | foo( int data )
> | {
> | this->foo('X');
> | }
> |
> | It said that foo was not a member of 'this',
>
> And correctly so.
But if you *really* want to call a constructor explicitly you can use
placement new:
foo(int d)
{
new (this) foo('x');
}
NB: this may not be a good idea if "foo" has (or will have at some unforseen
time in the future) base classes or members with non-trivial constructors.
Alan Griffiths | Also editor of: The ISDF Newsletter
Senior Systems Consultant, | (An Association of C and C++ Users publication)
CCN Group Limited. | (ISDF editor : isdf@octopull.demon.co.uk)
(agriffiths@ma.ccngroup.com) | (For ACCU see: http://bach.cis.temple.edu/accu)
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: aishdas@haven.ios.com (Micha Berger)
Date: 1996/05/01 Raw View
Frank Barrus asked about:
: ((foo*)this)->foo('X');
Which we've established is invalid, as a constructor is not a member
function, it just syntactically looks like one.
However, the workaround is trivial:
class foo {
public:
foo(const char c) { initialize(c); }
void initiatialize(const char);
:
:
}
void foo::initialize(const char c) {
// whatever used to be in the constructor
:
:
}
Then you can use the perfectly valid
((foo*)this)->initialize('X');
--
Micha Berger 201 916-0287 Help free Ron Arad, held by Syria 3427 days!
AishDas@haven.ios.com (16-Oct-86 - 8-Apr-96)
<a href=news:alt.religion.aishdas>Orthodox Judaism: Torah, Avodah, Chessed</a>
<a href=http://haven.ios.com/~aishdas>AishDas Society's Home Page</a>
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]