Article View: comp.sys.mac.programmer.help
Article #3Re: C++ - How to alter non-static, private array with a private member function?
From: Colen Garoutte-Carson
Date: Fri, 03 Nov 1995 14:31
Date: Fri, 03 Nov 1995 14:31
34 lines
1610 bytes
1610 bytes
In article <price-0211951815560001@price.mindspring.com>,
price@mindspring.com (Jeffery R. Price) wrote:
> I am using CW7 and am relatively new to C++. I have a class which has a
> private data member declared as:
> int Reg[6];
>
> I have a private member function which I want to change the contents of
> Reg[6]. If I do not declare Reg[6] as static, CW7 gives me errors anywhere
> I try to alter Reg[i] in my member function - saying "Illegal use of a
> non-static data member".
>
> If I declare Reg[6] as static int Reg[6] (which I do not really want to
> do), I get linker errors saying that "myClass::Reg" is undefined in
> "myClass.cp" (the source for the class).
>
> It seems odd that I can alter any non-static data members that aren't arrays.
Jeff,
Could you send me a source file that I can use to reproduce this?
The following works for me:
class x {
int myArr[20];
x(void);
};
x::x(void)
{
myArr[0] = 1;
}
- Colen Garoutte-Carson, Metrowerks Inc.
Technical Details
Message-ID:
<colen-0311951531110001@ip-pdx04-36.teleport.com>Path:
arc1-ca.pugleaf.net!ip-pdx04-36.teleport.com!userReferences:
<price-0211951815560001@price.mindspring.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!ip-pdx04-36.teleport.com!user From: colen@teleport.com (Colen Garoutte-Carson) Newsgroups: comp.sys.mac.programmer.help,comp.sys.mac.programmer.codewarrior,comp.lang.c++ Subject: Re: C++ - How to alter non-static, private array with a private member function? Date: Fri, 03 Nov 1995 15:31:11 +0100 Organization: Teleport - Portland's Public Access (503) 220-1016 Message-ID: <colen-0311951531110001@ip-pdx04-36.teleport.com> References: <price-0211951815560001@price.mindspring.com> NNTP-Posting-Host: ip-pdx04-36.teleport.com X-Newsreader: Yet Another NewsWatcher 2.0.1