Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2007

Tip: Looking for answers? Try searching our database.

CLI + this constructor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DaTurk - 15 May 2007 16:57 GMT
Hi,

I was wondering if there is a CLI equivalent to using the this keyword
to overload constructors.  You know where you would do something like

MyClass() : this("something")
{

}

MyClass(String name)
{

}

I can't seem to figure it out.

Thanks in advance
David Anton - 15 May 2007 18:59 GMT
Unfortunately not.
Signature

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI

> Hi,
>
[quoted text clipped - 14 lines]
>
> Thanks in advance
Ben Voigt - 15 May 2007 22:27 GMT
> Hi,
>
> I was wondering if there is a CLI equivalent to using the this keyword
> to overload constructors.  You know where you would do something like

Constructor chaining isn't permitted in C++, it would violate object
lifetime rules.  In .NET, an object is alive before the first user code in
any constructor starts running.  In C++, the object is constructed
piecemeal, and each subobject becomes alive when its constructor starts.
Being able to call a different constructor, would imply the object is born
twice, which isn't allowed.  Why this restriction applies to ref classes,
which follow .NET lifetime rules, I don't know.  But, you can certainly have
a reusable helper function called from more than one constructor (you can't
reuse base and member initialization expressions though).

> MyClass() : this("something")
> {
[quoted text clipped - 9 lines]
>
> Thanks in advance

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.