error C2512: no appropriate default constructor



I have some problems with the instantiating new objects. For example I have
the following code

//Headerfile (Texture1D.h>
#pragma once
#using <mscorlib.dll>
#include <osg/Texture1D>
#include <osg/Texture>
#include <managedosg/Texture.h>

namespace ManagedOsg
{
public __gc class Object;
public __gc class Image;
public __gc class Texture1DSubloadCallback;

public __gc class Texture1D : public ManagedOsg::Texture
{

public:
Texture1D(osg::Texture1D* unmanagedObject);
Texture1D(){};
ManagedOsg::Image *getImage();
};
}

//Cppcode (Texture1D.cpp>
#include <managedOsg/Texture1D.h>

ManagedOsg::Texture1D::Texture1D(osg::Texture1D* unmanagedObject)
{
_unmanagedObject = unmanagedObject;
}

ManagedOsg::Image *ManagedOsg::Texture1D::getImage()
{
return new
ManagedOsg::Image(static_cast<osg::Texture1D*>(_unmanagedObject)->getImage());
}

When i compile this i get an error C2512: 'ManagedOsg::Image' : no
appropriate default constructor available. When i look at the
ManagedOsg::Image class i have the following code

//Header file
#pragma once
#using <mscorlib.dll>
#include <osg/Image>
#include <osg/Object>
#include <managedosg/Object.h>

namespace ManagedOsg
{
public __gc class Object;
public __gc class Image : public ManagedOsg::Object
{

public:
Image(osg::Image* unmanagedObject);
Image();
};
}

//Cppfile
#include <managedOsg/Image.h>

ManagedOsg::Image::Image()
{
_unmanagedObject = new osg::Image();
}

ManagedOsg::Image::Image(osg::Image* unmanagedObject)
{
_unmanagedObject = unmanagedObject;
}

The image.cpp compiles without any error. When I change the getImage()
method to for example

return new ManagedOsg::Image()

the same eroor is happening. Compiling goes correctly if i return an NULL
value so i no for sure that the problem is inside the Texture1D class. And it
has also nothing to do with the unmanaged argument because i get the same
error without an argument.

How can help me solving this problem?


.



Relevant Pages

  • error C2512: no appropriate default constructor
    ... #pragma once ... namespace ManagedOsg ... The image.cpp compiles without any error. ... value so i no for sure that the problem is inside the Texture1D class. ...
    (microsoft.public.dotnet.languages.vc)
  • Can I use gdi+ in vs 6?
    ... #pragma comment(lib, "gdiplus.lib") ... It compiles OK. ...
    (microsoft.public.vc.mfc)
  • Re: compilation directive
    ... And that's why I wouldn't use the pragma in this instance...you have the ... potential of creating something that compiles one way with one tool and ... keystrokes. ...
    (comp.lang.vhdl)