🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6863

Re: value of class object

#6863
From: Simon D
Date: Fri, 08 Apr 2005 11:35
33 lines
1585 bytes
"Boguslaw Fries" <boguslaw.fries@polivision.it> wrote in message
news:42566160$1@newsgroups.borland.com...
> Hello,
> I posted this question here because I dont know exactly which is the
> appropriate newsgroup for it. Sorry ;)
>
> I declare the class:
> class Myclass
> {
> private:
>     int iVal;
>     float  fVal;
> public:
>     Myclass( int i ) { iVal = i;}
>     Myclass( float f ) { fVal = f; }
> }
> Now in my program:
> Myclass M( 5 );
> int X;
>
> X = M; // X should obtain value 5
>
> How to implement extra things to do it? In fact I could use Variant class,
> but intentionally I do not.
> Best regards
>
> Boguslaw Fries

Try this
public:
    operator int(){return iVal;}

Simon.
Technical Details
Message-ID: <42566c79@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <42566160$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: "Simon D" <LightsOnNo1@home.org>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <42566160$1@newsgroups.borland.com>
Subject: Re: value of class object
Date: Fri, 8 Apr 2005 12:35:48 +0100
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 81.131.111.34
Message-ID: <42566c79@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1112960121 81.131.111.34 (8 Apr 2005 04:35:21 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail