Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

Error C2327

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kevin_g_frey@hotmail.com - 30 Mar 2005 03:17 GMT
Hello All,

I have effectively the following (part of a much bigger header):

namespace X
{

namespace Y
{

__gc public class EnvironmentList
{
  // rest of declaration
};

__gc public class AnotherClass
{
  public:
  __property EnvironmentList* get_EnvironmentList( ); // **!**

  private:
  EnvironmentList* p_EnvironmentList; // **!**
};

} // namespace Y

} // namespace X

When I compile this the two lines marked **!** produce error C2327
saying that "X::Y::AnotherClass::EnvironmentList" is not a type name,
static, or enumerator.

I can get around this by fully qualifying the type (eg.
X::Y::EnvironmentList) in each case, but would prefer not to do so
because I have other cases which work perfectly (different class names
however).

I thought this might be due to an ambiguity with an existing class
named EnvironmentList in another namespace, but cannot find any
reference to such in MSDN. In addition, I tried a simple test
application to show how CL reports ambiguities and it seems to report
them correctly.

Any help appreciated...
Tomas Restrepo \(MVP\) - 30 Mar 2005 04:05 GMT
Kevin,

> Hello All,
>
[quoted text clipped - 40 lines]
>
> Any help appreciated...

You're problem is that the property is called the same as the type, so by
the time the compiler parses the property declaration, it has introduced a
new name "EnvironmentList - the property", so when it parses the field
member declaration, it doesn't know whether you're referencing the property
or the type.

The fix is actually quite simple: Just move the field declaration before the
property declaration (or rename the property, but that's not needed here):

__gc public class AnotherClass
{
  private:
  EnvironmentList* p_EnvironmentList; // **!**
  public:
  __property EnvironmentList* get_EnvironmentList( ); // **!**

};

Signature

Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/

kevin_g_frey@hotmail.com - 30 Mar 2005 04:45 GMT
Thanks, Tom. I have in fact chosen to rename the property (it actually
makes it more consistent with some others we have). But at least I now
know what the problem is!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.