Hi everyone, Im using VS2008 and getting the following error message when I try to build the program which I have so far, I've looked around on the internet to try to understand this error but I'm still very confused any help you can offer me will be greatly appreshiated, thank you in advance.

for the main.cpp file it says this error message

error C2512: 'MyExaminerViewer' : no appropriate default constructor available

I've included my code I have so far below.


This is my main.cpp file:

#include "ImageLoadTest.h"

int main(void)
{
 MyExaminerViewer a = new MyExaminerViewer();

	return 0;
}

This is my LoadImageTest.cpp file:

#include "ImageLoadTest.h"


MyExaminerViewer::MyExaminerViewer( HWND parent, const char * filename )
	: SoWinExaminerViewer( parent )
  {
    // Coin should not clear the pixel-buffer, so the background image
    // is not removed.
    this->setClearBeforeRender( FALSE, TRUE );
  
  
    // Set up background scenegraph with image in it.
  
    this -> bckgroundroot = new SoSeparator;
    this -> bckgroundroot -> ref();
  
    SoOrthographicCamera * cam = new SoOrthographicCamera;
    cam -> position = SbVec3f(0, 0, 1);
    cam -> height = 1;
    // SoImage will be at z==0.0.
    cam -> nearDistance = 0.5;
    cam -> farDistance = 1.5;
  
    SoImage * img = new SoImage;
    img -> vertAlignment = SoImage::HALF;
    img -> horAlignment = SoImage::CENTER;
    img -> filename = filename;
  
    this -> bckgroundroot -> addChild( cam );
    this -> bckgroundroot -> addChild( img );
  
    // Set up foreground, overlayed scenegraph.
  
    this -> foregroundroot = new SoSeparator;
    this -> foregroundroot -> ref();
  
    SoLightModel * lm = new SoLightModel;
    lm -> model = SoLightModel::BASE_COLOR;
  
    SoBaseColor * bc = new SoBaseColor;
    bc -> rgb = SbColor(1, 1, 0);
  
    cam = new SoOrthographicCamera;
    cam -> position = SbVec3f(0, 0, 5);
    cam -> height = 10;
    cam -> nearDistance = 0;
    cam -> farDistance = 10;
  
    const double ARROWSIZE = 2.0;
  
    SoTranslation * posit = new SoTranslation;
    posit -> translation = SbVec3f(-2.5 * ARROWSIZE, 1.5 * ARROWSIZE, 0);
  
    arrowrotation = new SoRotationXYZ;
    arrowrotation -> axis = SoRotationXYZ::Z;
  
    SoTranslation * offset = new SoTranslation;
    offset -> translation = SbVec3f( ARROWSIZE / 2.0, 0, 0 );
  
    SoCube * cube = new SoCube;
    cube -> width = ARROWSIZE;
    cube -> height = ARROWSIZE / 15.0;
  
    this -> foregroundroot -> addChild( cam );
    this -> foregroundroot -> addChild( lm );
    this -> foregroundroot -> addChild( bc );
    this -> foregroundroot -> addChild( posit );
    this -> foregroundroot -> addChild( arrowrotation );
    this -> foregroundroot -> addChild( offset );
    this -> foregroundroot -> addChild( cube );
  } 

MyExaminerViewer::~MyExaminerViewer()
{

};

And this is my LoadImageTest.h file

#ifndef ImageLoadTest_H
#define ImageLoadTest_H

  #include <Inventor/Win/SoWin.h>
  #include <Inventor/Win/viewers/SoWinExaminerViewer.h>
  #include <Inventor/nodes/SoBaseColor.h>
  #include <Inventor/nodes/SoCone.h>
  #include <Inventor/nodes/SoCube.h>
  #include <Inventor/nodes/SoImage.h>
  #include <Inventor/nodes/SoLightModel.h>
  #include <Inventor/nodes/SoOrthographicCamera.h>
  #include <Inventor/nodes/SoRotationXYZ.h>
  #include <Inventor/nodes/SoSeparator.h>
  #include <Inventor/nodes/SoTranslation.h>
  
  #include <GL/gl.h>

class MyExaminerViewer : public SoWinExaminerViewer
{
	
public:
	MyExaminerViewer(HWND parent, const char * filename);
	MyExaminerViewer();
	~MyExaminerViewer();

private:
	
    SoSeparator * bckgroundroot;
    SoSeparator * foregroundroot;
    SoRotationXYZ * arrowrotation;

};

#endif

Recommended Answers

All 2 Replies

Okay I think I worked out the error I was getting I have added
MyExaminerViewer(){};
To my header file updated one shown below but I now get this error

error C2440: 'initializing' : cannot convert from 'MyExaminerViewer *' to 'MyExaminerViewer'

Please help me if you can, thank you in adanced.

Updated ImageLoadTest.h file

#ifndef ImageLoadTest_H
#define ImageLoadTest_H

  #include <Inventor/Win/SoWin.h>
  #include <Inventor/Win/viewers/SoWinExaminerViewer.h>
  #include <Inventor/nodes/SoBaseColor.h>
  #include <Inventor/nodes/SoCone.h>
  #include <Inventor/nodes/SoCube.h>
  #include <Inventor/nodes/SoImage.h>
  #include <Inventor/nodes/SoLightModel.h>
  #include <Inventor/nodes/SoOrthographicCamera.h>
  #include <Inventor/nodes/SoRotationXYZ.h>
  #include <Inventor/nodes/SoSeparator.h>
  #include <Inventor/nodes/SoTranslation.h>
  
  #include <GL/gl.h>

class MyExaminerViewer : public SoWinExaminerViewer
{
	
public:

	MyExaminerViewer(HWND parent, const char * filename);
	MyExaminerViewer(){};
	~MyExaminerViewer();

private:
	
    SoSeparator * bckgroundroot;
    SoSeparator * foregroundroot;
    SoRotationXYZ * arrowrotation;

};

#endif

The problem is at the first line in your main: MyExaminerViewer a = new MyExaminerViewer(); The new keyword dynamically allocates an instance of the specified class and returns a pointer to it. The correct usage of the default constructor is either MyExaminerViewer a; // shorthand for MyExaminerViewer a(); or MyExaminerViewer *a = new MyExaminerViewer; // same as above, empty () are implicit

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.