Re: XCode 3.0 header/scope/namespace issues?
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