Help needed in C++/CLI with error C2512: no appropriate default constructor available

Having this issue with C++/CLI that's troubling me for a real long time and almost everything I've tried has failed. The problem is when I'm trying to create an instance of the GenDen reference managed type. I keep encountering error C2512: 'Instruction::GenDen' : no appropriate default constructor available. I'm posting the pieces of code here:


Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// GenDen.h
#pragma once

#include "prm.h"

namespace Triad{

public ref class GenDen : public Prm
{
	public:
		GenDen();
		GenDen(Slots slot);
};
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// GenDen.cpp
#include "stdafx.h"
#include " GenDen.h"

using namespace Triad;

GenDen::GenDen (): Prm(){} //default constructor

GenDen::GenDen(Slots slot) : Prm()
{
	try{
		Initialize(slot);
	}
	catch(DenException^ e){
		throw e;
	}
}

void GenDen::Initialize(Slots slot){
	//Whole bunch of Code related to this Initialize function
}


Main Project File:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Instruction.cpp

#include "stdafx.h"
#include "Form1.h"
#include "GenDen.h"
#include "prm.h"

using namespace Instruction;

void Form1::OpenInstruction(void)
{
	try {
		
		Den = gcnew GenDen (Triad::Slots::Slot8); //results in error C2512: 'Instruction::GenDen' : no appropriate default constructor available

		//Den = gcnew GenDen ();	//declaring it like this also results in the same error C2512	
		
	}
	catch (Pier::PierException^ ge) {
		throw ge;
	}

}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//Form1.h
#pragma once

#include "prm.h"
namespace Instruction {

	ref class GenDen; 

	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
		}

	protected:
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private:
		void Open Instruction ();
	private:
		GenDen^ Den; //declaring a handle of GenDen managed type
	};
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//Prm.h

#pragma once

namespace Triad
{
	using namespace System;
	using namespace System::Windows::Forms;

	public enum class Slots{
		Slot1,
		Slot2,
		Slot3,
		Slot4,
		Slot5,
		Slot6,
		Slot7,
		Slot8,
		Slot9,
		Slot10,
		Slot11,
		Slot12,
		Slot13,
		Slot14,
		Slot15,
		Slot16,
		Slot17,
		Slot18,
		Slot19,
		Slot20
	};

	public ref class Prm{
	public:
		Prm(){ errorCode = 0; handle = 0; }
		
		virtual void Initialize(Slots slot){}
		virtual void Reset(){}
	};
}


Can anyone help me on where I'm going wrong? All this is being done in VS 2010 C++ .NET 4.0. I'm new to C++/CLI, and figuring out all the intricacies has been interesting (even though they took a while). But this particular issue is proving beyond me.

Thanks
Have you tried:

1
2
3
4

Den = gcnew Instruction::Gen( Slots::Slot8 ):

 


?
Topic archived. No new replies allowed.