Article View: borland.public.cppbuilder.nativeapi
Article #3756Re: Basic C++ Question...
From: pnunn
Date: Fri, 05 May 2006 04:20
Date: Fri, 05 May 2006 04:20
67 lines
2843 bytes
2843 bytes
Hi Pete,
Pete Fraser wrote:
> 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
The funciton basically takes a pointer and sets the derived class value
to that (I know that's not going to do it now).
I don't have a *table in the dervide classes.
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:
<445ad281@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<445a02bf$1@newsgroups.borland.com> <445a062c$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 Date: Fri, 05 May 2006 14:20:17 +1000 From: pnunn <pnunn@infoteq.com.au> User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Basic C++ Question... References: <445a02bf$1@newsgroups.borland.com> <445a062c$1@newsgroups.borland.com> In-Reply-To: <445a062c$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 144.137.61.115 Message-ID: <445ad281@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1146802817 144.137.61.115 (4 May 2006 21:20:17 -0700) Lines: 67 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail