c++这个程序编译时候没有错误,执行的时候出错了,求指点
//A.h#ifndef_A_H_#define_A_H_classA{public:voidshow();};#endif//B.h#ifndef_B_H_#defin...
//A.h
#ifndef _A_H_
#define _A_H_
class A
{
public:
void show();
};
#endif
//B.h
#ifndef _B_H_
#define _B_H_
#include"A.h"
class B: public A
{
public:
void show();
};
#endif
//X.h
#ifndef _X_H_
#define _X_H_
#include"A.H"
class X
{
public:
void abc(A *);
};
#endif
//X.cpp
#include"X.h"
void X::abc (A *p)
{
p->show();
}
//try.cpp
#include"X.h"
#include"B.h"
void main()
{
X X1;
A A1;
B B1;
X1.abc(&A1);
X1.abc(&B1);
}
X.OBJ : error LNK2001: unresolved external symbol "public: void __thiscall A::show(void)" (?show@A@@QAEXXZ)
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/1.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe. 展开
#ifndef _A_H_
#define _A_H_
class A
{
public:
void show();
};
#endif
//B.h
#ifndef _B_H_
#define _B_H_
#include"A.h"
class B: public A
{
public:
void show();
};
#endif
//X.h
#ifndef _X_H_
#define _X_H_
#include"A.H"
class X
{
public:
void abc(A *);
};
#endif
//X.cpp
#include"X.h"
void X::abc (A *p)
{
p->show();
}
//try.cpp
#include"X.h"
#include"B.h"
void main()
{
X X1;
A A1;
B B1;
X1.abc(&A1);
X1.abc(&B1);
}
X.OBJ : error LNK2001: unresolved external symbol "public: void __thiscall A::show(void)" (?show@A@@QAEXXZ)
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/1.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe. 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询