Article View: borland.public.cppbuilder.nativeapi
Article #3746Basic C++ Question...
From: pnunn
Date: Thu, 04 May 2006 13:33
Date: Thu, 04 May 2006 13:33
45 lines
2342 bytes
2342 bytes
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:
<445a02bf$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!news.glorb.com!feeder.xsnews.nl!193.201.147.66.MISMATCH!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f15d7bde0eba2566,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 04 May 2006 23:33:25 +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: Basic C++ Question... Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 144.137.61.115 Message-ID: <445a02bf$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1146749631 144.137.61.115 (4 May 2006 06:33:51 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!news.glorb.com!feeder.xsnews.nl!193.201.147.66.MISMATCH!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail