concreteclass

Access “this” pointer of concrete class from interface

不羁岁月 提交于 2019-12-22 19:13:08
问题 After writing a test, I determined that the this pointer in an interface is not equal to the this pointer of the concrete class, meaning I can't just use a C-style cast on it. class AbstractBase {...}; class AnInterface { public: AnInterface() {...} // need AbstractBase * here ~virtual AnInterface() {...} // and here }; class Concrete : public AbstractBase, public AnInterface {}; My interface needs a base class pointer to the concrete class inheriting it in the constructor and destructor in

internal member in an interface

妖精的绣舞 提交于 2019-12-13 12:23:44
问题 I have a list of objects implementing an interface, and a list of that interface: public interface IAM { int ID { get; set; } void Save(); } public class concreteIAM : IAM { public int ID { get; set; } internal void Save(){ //save the object } //other staff for this particular class } public class MyList : List<IAM> { public void Save() { foreach (IAM iam in this) { iam.Save(); } } //other staff for this particular class } The previous code doesn't compile because the compiler requires all

Access “this” pointer of concrete class from interface

筅森魡賤 提交于 2019-12-06 06:02:56
After writing a test, I determined that the this pointer in an interface is not equal to the this pointer of the concrete class, meaning I can't just use a C-style cast on it. class AbstractBase {...}; class AnInterface { public: AnInterface() {...} // need AbstractBase * here ~virtual AnInterface() {...} // and here }; class Concrete : public AbstractBase, public AnInterface {}; My interface needs a base class pointer to the concrete class inheriting it in the constructor and destructor in order to handle interface related registration and deregistration. Every concrete object that inherits

internal member in an interface

我只是一个虾纸丫 提交于 2019-12-04 22:14:32
I have a list of objects implementing an interface, and a list of that interface: public interface IAM { int ID { get; set; } void Save(); } public class concreteIAM : IAM { public int ID { get; set; } internal void Save(){ //save the object } //other staff for this particular class } public class MyList : List<IAM> { public void Save() { foreach (IAM iam in this) { iam.Save(); } } //other staff for this particular class } The previous code doesn't compile because the compiler requires all the interface members to be public. internal void Save(){ But i don't want to allow the from outside my