views:

38

answers:

2

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
        }       
    };
}
+1  A: 

if CFigure::area() and CFigure::circumference() are abstract functions then put = 0 in declaration:

    virtual double area() = 0;
    virtual double circumference() = 0;
Dialecticus
+1  A: 

Probably you haven't defined area and circumference.

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.,

Alf P. Steinbach