473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

pointers-to-pointers and class children

I'm creating managed classes in an managed application, and believe I've
seen the following generate a compile error:

__gc class Parent_Class {} ;
__gc class Child_Class : public Parent_Class {} ;

__gc class Other_Class
{
public:
void Method_1( Parent_Class** pc_ptr_ptr ) {}

void Method_2( )
{
Child_Class* child ;

Method_1( &child ) ; // error
}
} ;

The error is something like " can't convert Child_Class __gc* __gc* to
Parent_Class __gc* __gc* ".

This seems odd. Why can't it convert to pointer-to-a-pointer of a child to a
pointer-to-a-pointer of its parent class?

[==Peteroid==]

PS - its possible this is one of those "there is a bug somewhere else"
cases, but thought i'd write anyway....hehe

Nov 17 '05 #1
2 901
Peteroid wrote:
This seems odd. Why can't it convert to pointer-to-a-pointer of a
child to a pointer-to-a-pointer of its parent class?


This is standard C++. Child* -> Base* is OK, Child** to Base** is not OK

This is simply a matter of consistency with the C++ type system - a pointer
is not a class, so there is no inheritance relationship between two pointer
types (and hence no implicit conversion in either direction). Base** is no
more a "parent" to Child** than float** is to int**.

-cd
Nov 17 '05 #2
Thanks, Carl!

So I'm not crazy, that is the way it is. Just wanted to be sure it wasn't
something else dumb I might have been doing...hehe

[==Peteroid==]

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:eW**************@TK2MSFTNGP11.phx.gbl...
Peteroid wrote:
This seems odd. Why can't it convert to pointer-to-a-pointer of a
child to a pointer-to-a-pointer of its parent class?
This is standard C++. Child* -> Base* is OK, Child** to Base** is not OK

This is simply a matter of consistency with the C++ type system - a

pointer is not a class, so there is no inheritance relationship between two pointer types (and hence no implicit conversion in either direction). Base** is no more a "parent" to Child** than float** is to int**.

-cd

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PF | last post by:
Hello, I'm pleased to see activity on this topic as it pains me to write "classmethod" two pages of code after the method definition. However I find the decorators to obfuscate the syntax and...
2
by: Krzysztof Stachlewski | last post by:
I tried to run the following piece of code: Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> o = object() >>> o.a...
15
by: Tee | last post by:
Hi, I have a base usercontrol with a method (blank method, no code), I have another few usercontrols that will inherit this base usercontrol, but I want to force all the usercontrol that...
1
by: Sowen | last post by:
Hi, all for example in my parent class, I define "virtual bool operator==(const parent &other);" In my children class, I need to override this method, how can I convert "parent &other" to...
12
by: Sunny | last post by:
Hi All, I have a serious issue regarding classes scope and visibility. In my application, i have a class name "TextFile", and also a few other classes like "TotalWords", "TotalLines" and etc..,...
4
by: kikazaru | last post by:
Can I write methods in one class A, that use methods in another base class B, in such a way that I can make a class C1 that inherits A and B1 (a child of B) so that the methods in A use the...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
28
by: =?iso-8859-1?q?Luis_M._Gonz=E1lez?= | last post by:
I've come across a code snippet in www.rubyclr.com where they show how easy it is to declare a class compared to equivalent code in c#. I wonder if there is any way to emulate this in Python. ...
0
by: abrosey | last post by:
The error is surrounded in stars near the bottom of the code, any help would be appreciated! namespace USDP.eCFUtilities { /// <summary> /// Summary description for CatalogHelper ///...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.