I have a class created in C#, and I want to reference a C++ class that was created. When I try to create an instance of the C++ class in C#, it can see the default constructor, but it can't see the constructor with arguments.
C++ cppClass code:
cppClass:: cppClass(const char* charArray)
C# code:
cppClass temp = new cppClass(); // <-- This works.
cppClass temp = new cppClass("Take 2"); // <-- This does not work.
When I use the second code, I get cppClass does not contain a constructor that takes 1 argument
.
I've set up the reference from the C# project to the C++, it can see the structs and the default constructor, but it can't see the one with arguments. Do I need to write a wrapper to be able to pass arguments?
If that is your actual code then the constructor is private
by default. Check the header to make sure the constructor is in a public
section:
public:
cppClass::cppClass(const char*)