🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Basic C++ Question...

#3747
From: Pete Fraser
Date: Thu, 04 May 2006 13:48
51 lines
2545 bytes
I think we need to see the code in the base class that sets the table ptr.
Also, do you have a *table in the derived classes?
Rgds Pete

"pnunn" <pnunn@infoteq.com.au> wrote in message 
news:445a02bf$1@newsgroups.borland.com...
> Folks.. I'm stuck on a problem that should be easy to sort out but I can't 
> get to work.
>
> I have a base class defined that has a pointer to a structure in it.
>
> struct stateTable *table;
>
> and a public function setTable that takes a passed in pointer and sets 
> table to it...
>
> In the derived class I have (in the constructor)
>
>    struct stateLine binTable[] =
>    {
>    //current state, A0, A1, next state
>    {1, High, Low, 2},
>    {1, High, High, 4},
>    {1, Low, High, 5},
>    {2, Low, Low, 1},
>    {2, High, High, 4},
>    {4, High, Low, 3},
>    {3, Low, Low, 1},
>    {3, Low, High, 4},
>    {5, High, High, 4},
>    {5, Low, Low, 1}
>    };
>
>    setTable(binTable);
>
> Now.. when I go to use table in other functions.. table points to nothing 
> useful.. and I guess its because as binTable goes out of scope, so does 
> the memory its using... so I guess I can see why its not working, but, I 
> can't work out how to make it work.
>
> If I have a stateTable* in the derived class, how do I dynamically make 
> the table and pass it to the base class?
>
> I'd really rather build the table as the above code shows, but then how do 
> I pass that to the base class and have it still be there?
>
> I know this is basic C++, but any help greatly appreciated.
>
> Ta.
>
> Peter. 
Technical Details
Message-ID: <445a062c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <445a02bf$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f15d7bde0eba2566
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Pete Fraser" <pete.nospam.fraser.nospam@frasersoft.nospam.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <445a02bf$1@newsgroups.borland.com>
Subject: Re: Basic C++ Question...
Date: Thu, 4 May 2006 14:48:32 +0100
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 80.175.251.18
Message-ID: <445a062c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1146750508 80.175.251.18 (4 May 2006 06:48:28 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail