Article View: borland.public.cppbuilder.nativeapi
Article #6791Re: value of class object
From: Alan Bellingham
Date: Mon, 11 Apr 2005 08:58
Date: Mon, 11 Apr 2005 08:58
51 lines
2674 bytes
2674 bytes
"JD" <nospam@nospam.com> wrote: >"Boguslaw Fries" <boguslaw.fries@polivision.it> wrote: >> >>Now in my program: >>Myclass M( 5 ); >>int X; >> >>X = M; // X should obtain value 5 > >That is not the case (that X == 5) and i doubt that that will >even compile. I think you misunderstand the gentleman. He's asking how to ensure that after the statement, X will contain the value 5. And no, it won't compile as is. He's asking what changes to make to the class so that a) it will compile, and b) that after that statement, X contains the value 5. He's wanting something that works like a VARIANT. > The line: > > Myclass M( 5 ); > >creates an instance of Myclass named 'M', passing 5 to it's >constructor (and does nothing else with it). The value of 'M' >is in reality a 32bit pointer that must be correctly dereferenced >to access class members or methods. In reality, nothing of the sort. (Perhaps you're thinking of a different programming language. Java or C#, perhaps?) M is on the stack. It is a class, containing one int (currently set to 5) and an indeterminate float value. No pointer is involved, any more than if M was an int rather than a MyClass. >>How to implement extra things to do it? > >Here's a sample class that I use to get version info from my >application. All you have to do is #include the header and add >the lines (note that it support multiple languages as well): [snip example of a TVersionInformation class] To be honest, I haven't a clue what your example code has to do with Boguslaw's question, and I doubt he has either. Are you sure it's not the answer to a different question? Alan Bellingham -- ACCU Conference 2005 - 20-23 April, Randolph Hotel, Oxford, UK
Technical Details
Message-ID:
<oeek519rq5reo06st5jim6h3ucptm7h5dh@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<42566160$1@newsgroups.borland.com> <4259d766$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,1f4e1214f81b2544 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Alan Bellingham <alanb@episys.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: value of class object Date: Mon, 11 Apr 2005 09:58:11 +0100 Reply-To: alanb@episys.com Message-ID: <oeek519rq5reo06st5jim6h3ucptm7h5dh@4ax.com> References: <42566160$1@newsgroups.borland.com> <4259d766$1@newsgroups.borland.com> X-Newsreader: Forte Agent 2.0/32.652 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 193.129.251.253 X-Trace: newsgroups.borland.com 1113209890 193.129.251.253 (11 Apr 2005 01:58:10 -0800) Lines: 51 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail