I have three interfaces, lets call them General, Client, Server.
public interface General
{
public Value{get;}
}
public interface Client : General
{}
public interface Server: General
{
public Value{set;}
}
public class Something : Server, CLient{
}
public class Test{
Something a = new Something();
a as General;
a.Value = 5;
}
THis is essentially what I'm trying to do, but all three interfaces are
in MCPP and for some reason when I try to write to the property Value
it says it can not be accessed. What am I doing wrong? Here is the
actual interface code below, I'll trim out the extraneous methods.
#pragma once
namespace Provider
{
public __gc __interface General : public IDisposable
{
public:
__property NameValueCollec tion* get_Parameters( void);
};
};
#pragma once
#include "General.h"
namespace Provider
{
public __gc __interface Server : public General
{
public:
__property void set_Parameters( NameValueCollec tion
*parameters);
};
};
and the CLient, or third interface just adds an additional method. All
I'm trying to do is have the classes that implement server be able to
set properties, and otherwise they can only get them. Thank you in
advance for any help. 2 3441
Well, it's hard to say why your code doesn't run since the code you
posted doesn't even compile. The main problem is the line "a as
General;" which, as written, is completely meaningless --- and,
depending on what the actual code in your program is, is probably the
location of the bug.
I'm going to guess that that line, and the one before it, should
actually be written as:
General a = new Something() as General;
If so, then that's the problem right there. General has a getter, but
no setter. If you were to write the line as,
Server a = new Something() as Server;
then the assignment works fine.
DaTurk wrote: I have three interfaces, lets call them General, Client, Server.
public interface General { public Value{get;} }
public interface Client : General {}
public interface Server: General { public Value{set;} }
public class Something : Server, CLient{ }
public class Test{ Something a = new Something(); a as General; a.Value = 5; }
THis is essentially what I'm trying to do, but all three interfaces are in MCPP and for some reason when I try to write to the property Value it says it can not be accessed. What am I doing wrong? Here is the actual interface code below, I'll trim out the extraneous methods.
#pragma once
namespace Provider {
public __gc __interface General : public IDisposable {
public: __property NameValueCollec tion* get_Parameters( void); }; };
#pragma once
#include "General.h"
namespace Provider {
public __gc __interface Server : public General {
public: __property void set_Parameters( NameValueCollec tion *parameters); }; };
and the CLient, or third interface just adds an additional method. All I'm trying to do is have the classes that implement server be able to set properties, and otherwise they can only get them. Thank you in advance for any help.
HI,
Yeah, I wrote the code on the fly just to give you an idea of what I
was trying to do because the actual classes are quite large. From what
I've found out today, you can't implemetna property like that. I mean,
have one interface with the get, and have an implementing interface
with a set. If you found some way to get that to work in C# I would be
very intrested to see the code. The only reason it works for me is
because the interfaces are in managed c++. Thanks for the response This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joe Delphi |
last post by:
Does Visual Basic support multiple inheritance? That is one child
class inheriting from more than one parent class.
JD
|
by: Tony Johansson |
last post by:
Hello experts!
I have a small program that is using multiple inheritance.
There are 4 classes involved
I get 4 compile error that I can't figure out why.
It's this row which is located in the main program see below that is causing
these compile errors.
cout << p->getName() << endl;
Here is the first compile error the other might be a consequesce of the
first one.
|
by: Matthew Louden |
last post by:
I want to know why C# doesnt support multiple inheritance? But why we can
inherit multiple interfaces instead? I know this is the rule, but I dont
understand why. Can anyone give me some concrete examples?
|
by: jon |
last post by:
How can I call a base interface method?
class ThirdPartyClass :IDisposable { //I can not modify this class
void IDisposable.Dispose() {
Console.WriteLine( "ThirdPartyClass Dispose" );
}
}
class MyClass :ThirdPartyClass, IDisposable {
void IDisposable.Dispose() {
|
by: MAHESH MANDHARE |
last post by:
Hi ,
Can Anyone explain me exactly why multiple inheritance not used in java and c#
thanks,
Mahesh
--
Have A Good Day,
Mahesh,
Maheshmandhare@yahoo.co.in
| |
by: David |
last post by:
Is there a good workaround the lack of multiple-inheritance? What if some
classes expose A's properties and some B's and others expose A's and B's? I
have an A class, a B class, an AB class and an AB : C class. The AB class
has code copied into it from both A and B.
Thanks.
|
by: Tapeesh |
last post by:
I have a following piece of code. The code was compiled using g++
class A
{
public :
virtual void fn() = 0;
};
class B: virtual private A
{
|
by: John |
last post by:
Hi All,
Although C# has Generics, it still does not support the generic
programming paradigm. Multiple inheritance is required to support real
generic programming. Here is a simple design pattern to illustrate this.
Problem:
I need to expose two lists of objects from a high-level class. I would
like to expose these lists as read-only, but require write access
internally.
|
by: Paul McGuire |
last post by:
On May 25, 8:37 am, Michael Hines <michael.hi...@yale.eduwrote:
Here's a more general version of your testing code, to detect *any*
diamond multiple inheritance (using your sample classes).
-- Paul
for cls in (A,B,C,D):
seen = set()
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |