#include <iostream>
class ZZ
{
public:
void print1()
{
std::cout << "hello\n";
}
};
class YY : public ZZ
{
public:
void print()
{
using ZZ::print1;
print1();
}
};
int main()
{
YY temp;
temp.print();
getchar();
return 0;
}
If I compile the code, I would get the error:
error: 'ZZ' is not a namespace or unscoped enum using ZZ::print1;
. I'm confused.
If I define another namespace in this file, like this:
namespace tt{
int a;
}
And I use this in the derived function print
, like this:
void print()
{
using namespace tt;
a = 1;
}
The code will be compiled successfully.But I think ZZ
is a namespace as well because if I use the ZZ
like this:
public:
using ZZ::print1;
void print()
{
print1();
}
This code will be compiled successfully as well.
So I don't know why this error happened when I use using ZZ::print1
in the derived function print
.