|
What is the difference between normal C++, C++/CLI and managed C++? I do know the difference between normal C++ and managed C++, but what the heck is C++/CLI??
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
wikipedia:
"C++/CLI (Common Language Infrastructure) is the newer language specification due to supersede Managed Extensions for C++. Completely reviewed to simplify the older Managed C++ syntax, it provides much more clarity over code readability than Managed C++. Like Microsoft .NET, C++/CLI is standardized by ECMA. It is currently only available on Visual C++ 2005."
http://en.wikipedia.org/wiki/C%2B%2B/CLI
http://msdn2.microsoft.com/en-us/library/b23b94s7(en-us,vs.80).aspx
another msdn article which explains the New Language Design:
http://msdn2.microsoft.com/en-us/library/ms235215(VS.80).aspx
Tobias
|
|
|
|
|
why can't we create object of an abstract class?
|
|
|
|
|
MSDN help:
A member can only be defined in a derived type.
A type cannot be instantiated (can only act as a base type).
another resource:
http://cplus.about.com/od/cprogrammin1/l/bldef_abstract.htm
Definition: An abstract class can only be a base class for other classes. A class is abstract if it has any pure virtual functions.
This should explain your problem. (furthermore i think those facts are basic knowledge of progamming)
Tobias
|
|
|
|
|
are you calling into question the bases of OOP ?
|
|
|
|
|
I have a base shared library written in C++/CLI. It contains a pointer to an instance of an unmanaged class. I would like to expose this pointer to my C++/CLI executable that is using the library. At first I wrote this simple code:
public:
static property DataPointModel* DPModel
{
DataPointModel* get()
{
if( NULL == m_sharedPortsContainer )
{
DeserializeModel();
}
return m_sharedPortsContainer;
}
}
The DataPointModel class is actually implemented in an unmanaged library.
It appears that the compiler hides this function to all external libraries because it exposes an unmanaged pointer. Is there any way to get around this so that I can access this pointer?
-- modified at 17:51 Thursday 16th March, 2006
|
|
|
|
|
static property IntPtr DPModel
{
IntPtr get()
{
if( nullptr == m_sharedPortsContainer )
{
DeserializeModel();
}
return m_sharedPortsContainer;
}
}
I haven't tested this, but I believe it might work. You will have to cast, the returned value to your DataPointModel*, however.
|
|
|
|
|
First of all, this is the (Managed) C++/CLI Forum! You may have better luck posting in the Visual C++ Forum.
|
|
|
|
|
Alright, im working on a Plugin script in my application.
Every plugin got saved in a seperated Dll with a main class:
public ref class Plugin : public PluginInterface::IPlugin
IPlugin is a abstract class with some basic info like Name, Date, Descryption and a few virtual methods, Initialize and so on.
Now my load function:
void cPlugins::AddPlugin(System::String ^FileName)<br />
{<br />
Assembly^ PluginAssembly = Assembly::LoadFrom(FileName);<br />
<br />
for each (Type^ PluginType in PluginAssembly->GetTypes()){<br />
if (PluginType->IsPublic){<br />
if (!PluginType->IsAbstract){<br />
Types::AvailablePlugin^ NewPlugin = gcnew Types::AvailablePlugin();<br />
NewPlugin->Instance = dynamic_cast<IPlugin^>(Activator::CreateInstance(PluginAssembly->GetType(PluginType->ToString())));<br />
<br />
if ((NewPlugin != nullptr)&&(NewPlugin->Instance!=nullptr)){<br />
NewPlugin->AssemblyPath = FileName;<br />
NewPlugin->Instance->Host = this;<br />
NewPlugin->Instance->Initialize();<br />
<br />
if (!this->AvailPlugins)<br />
this->AvailPlugins = gcnew Types::AvailablePlugins();<br />
this->AvailPlugins->Add(NewPlugin);<br />
}<br />
}<br />
}<br />
}<br />
}
or at least, code above is something like that. i tried to many different things. The definition of AvailablePlugin is like this,
public ref class AvailablePlugin<br />
{<br />
public:<br />
IPlugin^ Instance;<br />
String^ AssemblyPath;<br />
};
Now, for some or other reason, He wont give me a valid class. << Means, that the when i do a typecheck, he just says its a total different type. dynamic_cast<iplugin^>(Activator::CreateInstance(***)) wont agree with it.
How can i make this work? can anyone help?
Thanks already
|
|
|
|
|
Is this line correct?
NewPlugin->Instance = dynamic_cast(Activator::CreateInstance(PluginAssembly->GetType(PluginType->ToString())));
I can't see the type your are casting to? Probably a typo in your post. Wasn't it dynamic_cast < type-id > ( expression ) I guess you are using <IPlugin^>, don't you?
|
|
|
|
|
yes i am, as i already said, that piece of code is all messed up
|
|
|
|
|
I every one,
I want to know the maximum characters a String type can contain . 256 characters or more ?
|
|
|
|
|
|
Nemanja Trifunovic wrote: More
you couldn't answer more precisely on what the guy asked
|
|
|
|
|
as opposed to "your in the wrong group,
your in the wrong group"
|
|
|
|
|
I am feeling a little hate here! Nevertheless, the "prime directive" is to post your questions in the correct forum. However, we do need to use a little tact in informing someone of the "prime directive".
|
|
|
|
|
No hate... And it wasn't directed
at you, as your help is invaluable
to me and to others I'm sure.
Seems some just live to tell others
they've posted in the wrong group.
Group is quite, maybe we could just
start posting the managed answer to
whatever question was asked in
addition to telling the OP the error
of their ways.
Cheers,
Paul
|
|
|
|
|
I understand! I guess doing that is an easy way to increase your number of posts!
|
|
|
|
|
I sorry to post my messsage in a wrong group . But I don't know where is the accurate group for my message ?
-- modified at 2:13 Thursday 16th March, 2006
|
|
|
|
|
pardon ?
what the problem ?
i sincerely don't understand your intervention...
what does that mean ?
and how does it relates to me ?
|
|
|
|
|
Ok . It's more . But how much exactly ? can I set 4096 characters to a String ?
|
|
|
|
|
A 4096-character string wouldn't be a problem. You have a lot of room to work with? Just remember that the string-type does not mutate. Everytime you make a change, .NET creates a new instance with the change. There may be exceptions to this but a string is pretty much immutable. Of course, StringBuilder is mutable but it has its own overhead.
|
|
|
|
|
Since the String.Length property's type is Int32, it might be 2,147,483,647. Using large strings, can lead to a HEAP of trouble!
-- modified at 17:58 Wednesday 15th March, 2006
|
|
|
|
|
HEAP of trouble...
|
|
|
|
|
I'm testing my parallel port with the Borland C 5.5 compiler:
.....
.....
.....
while(!kbhit())
{
int data;
data=(inp32)(PORT+1);
gotoxy(3,10);
printf("Data available in status register: %3d (Decimal), %3X (hex)\n", data, data);
printf("\n Pin 15: %d",(data & 0x08)/0x08);
printf("\n Pin 13: %d",(data & 0x10)/0x10);
printf("\n Pin 12: %d",(data & 0x20)/0x20);
printf("\n Pin 11: %d",(data & 0x80)/0x80);
printf("\n Pin 10: %d",(data & 0x40)/0x40);
delay(10);
}
When I compile the program, it gives the following error:
Error: Unresolved external '_delay' reference from location
What is the use of delay(10) and gotoxy(3,10) in the program? Please advice.
Thank You
-- modified at 10:43 Wednesday 15th March, 2006
|
|
|
|