Sha256: 199a9d82d3daa310fcb7a1848f062653e1433b8883cbf778135b22c3a07f6b8f

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

#ifndef __ENCAPSULATE_H__
#define __ENCAPSULATE_H__

namespace encapsulation {
  class Base {
    protected:
      virtual int protectedMethod() {
        return -1;
      }
    public:
      virtual int fundamentalTypeVirtualMethod() = 0;
      virtual ~Base() {}
      virtual Base *userDefinedTypeVirtualMethod() = 0;
  };
  
  class Extended : public Base {
    private:
      void privateMethod() {
      }
    protected:
      int protectedMethod() {
        return 1;
      }
    public:
      Extended() {}
      int publicMethod() {
        return this->protectedMethod();
      }
      int fundamentalTypeVirtualMethod() {
        return 1;
      }
      Base *userDefinedTypeVirtualMethod() {
        return new Extended();
      }
  };
  
  class ExtendedFactory {
  public:
    ExtendedFactory() {}
    Base *newInstance() {
      return new Extended();
    }
  };

  class ArgumentAccess {
    struct PrivateStruct { }; 

  protected:
    struct ProtStruct { };

  public:
    struct PublicStruct { 
      PublicStruct() {}
    };

    ArgumentAccess() {}
    ~ArgumentAccess() {}

    // Only wrap methods that use public structs
    void wrapMePrivate(PrivateStruct st) { }
    void wrapMeProtected(ProtStruct st) { }
    void wrapMePublic(PublicStruct st) { }

    // And make sure it works with multiple arguments
    void wrapMeManyNo(int a, float b, PublicStruct st1, ProtStruct st2) { }
    void wrapMeManyYes(int a, float b, PublicStruct st1) { }

  };
}

#endif

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rbplusplus-1.4.0 test/headers/class_methods.h
rbplusplus-1.3.0 test/headers/class_methods.h
rbplusplus-1.2.1 test/headers/class_methods.h
rbplusplus-1.2.0 test/headers/class_methods.h
rbplusplus-1.1.0 test/headers/class_methods.h
rbplusplus-1.0.3 test/headers/class_methods.h
rbplusplus-1.0.1 test/headers/class_methods.h
rbplusplus-1.0 test/headers/class_methods.h
rbplusplus-0.9.1 test/headers/class_methods.h
rbplusplus-0.9 test/headers/class_methods.h