|
I have an unmanged C++ class I have written in an unmanged dll. I have a managed dll that references the unmanaged dll. Can a class in the managed dll derive from the unmanaged class?
Using Visual Studio 2008
Started by NotDan on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Can do is wrap you unmanaged class in a manager wrapper and then derive from that..
|
|
Hello!
I need to mix Objective-C and C++. I would like to hide all the C++ stuff inside one class and keep all the others plain Objective-C. The problem is that I want to have some C++ classes as instance variables. This means they have to be mentioned...
Started by zoul on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Then....
This way source files from .cpp or .m to .mm) .
Define an objective-c protocol for the API and then provide an implementation of that protocol using your Objective-C++ class.
This sounds like a classic use for an interface/@protocol.
|
|
Thanks to all that responded to my previous thread. There is still a problem with this simple program that I would like to solve. I am trying to import one class into another as a member object. The output of this program is confusing, though. As a test...
Started by Patrick Hogan on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Marking explicit will avoid implicit casts from the argument type to the class type are working on, now I understand this is probably for learning)
class Structure1 // typedef removed.
Block.
|
Ask your Facebook Friends
|
Is it possible to define C++ classes Foo and Bar s.t.
class Foo { Bar makeBar(); }; class Bar { Foo makeFoo(); };
?
Thanks!
Started by anon on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
class Foo; class Bar; class Foo ....
For example, in Foo.h , add:
class Bar; class Foo { Bar makeBar(); };
Yes it is, you just have to put forward declarations at the top.
You can do it with a forward declaration.
|
|
Is there anyway to declare an object of a class before the class is created in C++? I ask because I am trying to use two classes, the first needs to have an instance of the second class within it, but the second class also contains an instance of the ...
Started by Matt Pascoe on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
class B { public: A *itemA; }; class A { public: B *itemB;....
You can't declare an instance of an undefined class but you can declare a pointer to one:
class A; // Declare that we have a class A without defining it yet.
|
|
When can an object of a class call the destructor of that class, as if it's a regular function? Why can't it call the constructor of the same class, as one of its regular functions? Why does the compiler stops us from doing this?
For example:
class c ...
Started by Vinayaka Karjigi on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
You can invoke the constructor of an instance's class using typeof :
class c { public: void add to placement new:
class c { public: void add() ; c(); ~c() ; }; int main() { c objC ; objC....
Be there.
|
|
Let's say I have 2 classes like this:
public class A { public string P1{ get; set; } public string P2{ get; set; } } public class B { public string P3{ get; set; } public string P4{ get; set; } }
and I need a class like this:
public class C { public string...
Started by Omu on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
But maybe not pretty:
public class C
{
public A APart { get; set; }
public B BPart { get; set; set; } } class B : IB { string P3 { get; set; } string P4 { get; set; } } class C : IA, IB { string can't , as multiple....
|
|
I know that I can do:
class Foo;
but can I forward declare a class as inheriting form another, like:
class Bar {}; class Foo: public Bar;
?
Thanks!
Started by anon on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
(Generally....
A forward declaration is only really useful for telling the compiler that a class with that name needs contextual information about the class, nor is it of any use to the compiler to tell it only a little bit about the class.
|
|
Is it possible to assign a base class object to a derived class reference with an explicit typecast in C#?.
I have tried it and it creates a run-time error.
Started by sahil garg on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
A reference to a derived class must actually refer to an instance of the derived class....
But you can assign an instance of a derived class to a variable of base class type.
No it is not possible, hence your runtime error.
|
|
How can I use a C++ class in C#? I know you can use DllImport and have the class as IntPtr, but then how would I call the functions inside the class? And I don't want to create a new method for each method in the class and export that, then there is not...
Started by ticpete on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
To use c++ class, C++\CLI option which you've started doing is....
If the DLL in question is accessible via COM, then use the COM interop to talk that way you're working in the same language before you transition to C# .
Regular .NET class.
|