Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: XE8 enterprise, property getters



Permlink Replies: 1 - Last Post: Mar 17, 2017 9:09 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Jan Dijkstra

Posts: 206
Registered: 11/4/99
XE8 enterprise, property getters
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 17, 2017 3:08 AM
When I have a class like
class TTest : public TComponent
{
private:
  UnicodeString __fastcall GetLanguage (int index);
 
public:
  __fastcall TTest (TComponent *owner);
 
  __property UnicodeString Language [int index] = { read = GetLanguage };
};
 
 
void sometest (void)
{
  TTest *test = new TTest (NULL);
 
  UnicodeString value = test->Language [2];
}

everything works as you would expect. I cannot directly access the GetLanguage member as it is private, but I can indirectly call it through the property declaration.

However, when I modify my class by adding a public member
  UnicodeString __fastcall  GetLanguage (UnicodeString const &languageId);

all of a sudden the code in function sometest fails to compile, and I get the error E2247 "__fastcall TTest::GetLanguage(int)" is not accessible.

And I fail to understand why that is. Based on the error message, the compiler picked the correct overloaded member function to call. It's still the same private member as before. But without the public overloaded member present, I can call the private one through the property, and with the public one I no longer can.
Remy Lebeau (Te...


Posts: 8,938
Registered: 12/23/01
Re: XE8 enterprise, property getters
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 17, 2017 9:09 AM   in response to: Jan Dijkstra in response to: Jan Dijkstra
Jan wrote:

However, when I modify my class by adding a public member

UnicodeString __fastcall  GetLanguage (UnicodeString const
&languageId);


all of a sudden the code in function sometest fails to compile, and I
get the error E2247 "__fastcall TTest::GetLanguage(int)" is not
accessible.

That is an old bug, it has been around for years (I can reproduce it in older
compilers). Don't overload property getters like you are trying to do.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02