==10.cpp
#include
#include
#include "10.h"
using namespace std;
using namespace A_A;
extern void geta(A22&);
int AA::aa = 0;
AA::AA(char* ss)
{
strcpy(s,ss);
}
void A22::show() const
{
cout<<aa<<endl;
}
A22::A22(char* s,int sz,int ops,int pii,string na):AA(s),size(sz),name(na)
{
aa++;
this->pi = new int;
*pi = pii;
}
A22::~A22()
{
cout<<"析构调用"<<endl;
delete pi;
}
A22::A22(const A22& a):AA((char*)a.s),size(a.size)
{
aa++;
this->ops = a.ops;
this->pi = new int;
*pi = *(a.pi);
this->name = a.name;
}
void A22::get()
{
cout<<aa<<endl;
}
void A22::gets()
{
cout<<*pi<<endl;
cout<<name<<endl;
}
void test(int a,int b,int c=11)
{
cout<<c<<endl;
}
int main()
{
A22 a3("ioi",21,122,1024,"China");
A22 a4 = a3;
a4.gets();
}
====10.h头文件
#ifndef _10H
#define _10H
#include
#include
using namespace std;
namespace A_A
{
class AA
{
private:
protected:
char s[10];
public:
AA(char* ss);
static int aa;
};
class A22:public AA
{
public:
friend void geta(A22&);
void show() const;
A22(char*,int,int ops,int,string);
static void get();
void gets();
int ops;
A22(const A22& a);
virtual ~A22();
private:
const int size;
int * pi;
string name;
};
void geta(A22& a)
{
cout<<"name = "<<a.name<<endl;
}
}
#endif
=====101.cpp
#include
#include
#include "10.h"
using namespace std;
using namespace A_A;
extern class AA;
extern class A22;
extern void geta(A22&);
vc 6.0上编译显示:
--------------------Configuration: 10 - Win32 Debug--------------------
Compiling...
101.cpp
D:\wpwpw\c的测试的代码\101.cpp(7) : warning C4091: 'extern ' : ignored on left of 'class AA' when no variable is declared
D:\wpwpw\c的测试的代码\101.cpp(8) : warning C4091: 'extern ' : ignored on left of 'class A22' when no variable is declared
D:\wpwpw\c的测试的代码\101.cpp(9) : error C2872: 'A22' : ambiguous symbol
Error executing cl.exe.
Creating browse info file...
10.exe - 1 error(s), 2 warning(s)
---报错提示的是:
101.cpp文件中的
=====101.cpp
#include
#include
#include "10.h"
using namespace std;
using namespace A_A;
extern class AA;
extern class A22;
extern void geta(A22&);------这行提示错误
请问这是怎么回事啊?希望能详细的解释下,怎么去解决