未解析的令牌 - c++
我正在努力解决我学习中的一课。我将在顶部有一个抽象类 CFigure,在下面有不同的图形,目前我已经制作了一个圆形类。我将从 C# 程序中调用它。
但是,当我尝试构建代码时,出现以下错误消息:
- unresolved token (06000001) arealBeregnerCPP.CFigure::area
- unresolved token (06000002) arealBeregnerCPP.CFigure::circumference
- 2 unresolved externals
我希望任何人都可以给我一个提示我做错了...谢谢!
这是我的程序:
// arealBeregnerCPP.h
#pragma once
using namespace System;
namespace arealBeregnerCPP {
public ref class CFigure
{
public:
virtual double area();
virtual double circumference();
};
public ref class CCircle : public CFigure
{
private:
double m_radius;
public:
CCircle(double radius)
{
m_radius = radius;
}
virtual double area() override
{
return 0; //not implementet
}
virtual double circumference() override
{
return 0; //not implementet
}
};
}
I am trying to solve a lesson in my study. I am going to have an abstract class, CFigure, on top and different figures below, currently I have made a circle class. I am going to call this from a C# program.
But when I try to build my code I get the following error messages:
- unresolved token (06000001) arealBeregnerCPP.CFigure::area
- unresolved token (06000002) arealBeregnerCPP.CFigure::circumference
- 2 unresolved externals
I hope anyone can give me a hint in what I do wrong... Thanks!
This is my program:
// arealBeregnerCPP.h
#pragma once
using namespace System;
namespace arealBeregnerCPP {
public ref class CFigure
{
public:
virtual double area();
virtual double circumference();
};
public ref class CCircle : public CFigure
{
private:
double m_radius;
public:
CCircle(double radius)
{
m_radius = radius;
}
virtual double area() override
{
return 0; //not implementet
}
virtual double circumference() override
{
return 0; //not implementet
}
};
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果
CFigure::area()
和CFigure::circumference()
是抽象函数,则将= 0
放入声明中:if
CFigure::area()
andCFigure::circumference()
are abstract functions then put= 0
in declaration:可能您还没有定义
面积
和周长
。由于您未能提供完整的代码,因此还有其他一些可能性,例如未能链接到相关文件。
顺便说一句,请不要将 c++/cli 问题标记为 c++。微软的c++/cli不是c++。它是一种类似于c++的语言,但它不是c++。
干杯&呵呵,
Probably you haven't defined
area
andcircumference
.Since you fail to present complete code there are some other possibilities, such as failing to link with the relevant files.
By the way, please don't tag c++/cli questions as c++. Microsoft's c++/cli is not c++. It's a language similar to c++, but it's not c++.
Cheers & hth.,