• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XCode 3.0 header/scope/namespace issues?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XCode 3.0 header/scope/namespace issues?


  • Subject: Re: XCode 3.0 header/scope/namespace issues?
  • From: Jeff DuMonthier <email@hidden>
  • Date: Sun, 25 Nov 2007 16:19:40 -0500

I have a simple code example which demonstrates one of the problems I am seeing, but I'm not sure why it is happening.

// Define a base class with an integer member
class c1
{
public:

  int i1;
};

// Define a subclass with public inheritance which accesses the integer member it inherits
class c2 : public c1
{
public:


  int getI();
};

int c2::getI()
{
  int i = i1;    // This works
  return i;
}

// Define a template base class with an integer member
template<typename tt>
  class tc1
  {
  public:

    tt t1;
    int i1;
  };

// Define a template subclass with public inheritance which accesses the integer member it inherits
template<typename tt>
class tc2 : public tc1<tt>
{
public:


    int getI();
  };

template<typename tt>
int tc2<tt>::getI()
{
int i = tc1<tt>::i1; // This works
i = i1; // This causes a compiler error: "error: 'i1' was not declared in this scope"
return i;
}


// instantiate the classes and the member functions
int test()
{
  c2 theC2;
  tc2<int> theTC2;

  int ic  = theC2.getI();
  int itc = theTC2.getI();
  return ic + itc;
}

************

Is this correct behavior, that a member function of a template class needs to explicitly scope data members (and presumably member functions) that it inherits? The same is not true of the non-template class. Is there another way around this? This is going to be a huge issue to fix otherwise. I've got a lot of template classes with inheritance. I'm not sure a using clause would work since a template is part of the scope. Some of the errors I see are integer constants "not defined in this scope" that are not even part of a template. Does a template member function somehow obscure all or some set of scopes? I'm not even using namespaces in this example, so that can't be it.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: XCode 3.0 header/scope/namespace issues, gcc 4.0 bug?
      • From: Jeff DuMonthier <email@hidden>
References: 
 >XCode 3.0 header/scope/namespace issues? (From: Jeff DuMonthier <email@hidden>)

  • Prev by Date: Re: Is XCode 3 SCM more dysfunctional than ever or am I doing something wrong?
  • Next by Date: Re: creating the svnusers Group
  • Previous by thread: XCode 3.0 header/scope/namespace issues?
  • Next by thread: Re: XCode 3.0 header/scope/namespace issues, gcc 4.0 bug?
  • Index(es):
    • Date
    • Thread