8 – Views Infinite Scroll class wrapper goes away when filtering using facets, changing my CSS styling

I have a page with custom css that uses display:grid for content output from my view.
The limit I have for what my view outputs is 30.

Since the views infinite scroll contains a wrapper around my content, my css grid styling is all there, however when I use my facet to filter anything with an output less than 30, the wrapper vanishes as does all the styling. The wrapper then becomes a different class, however I obviously can’t use display: grid in both classes since that would create a nested grid.

I’ve tried using jquery to attach a separate wrapper class based on if the infinite scroll class is there, and that didn’t work. Does anyone have any other ideas on what I can do?

Thank you!

unity – Checking if a base class type is of child class and accessing properties

I’m working on an inventory system similar to the Resident Evil games for a game jam. I wanted to practice using a little bit of inheritance, as well as ScriptableObjects as data containers, but I’m afraid I might have programmed myself into a corner.

I first declared an Item class

(CreateAssetMenu(fileName = "New Item", menuName = "Items/Item"))
public class Item : ScriptableObject
{
public string itemName = "Default Item";
public string itemDescription = "An item.";
public string itemID = "00";
public int quantity = 1;

public Sprite itemIcon;

public bool isStackable = false;

public static int idCounter = 0;

public enum ItemTypes
{
    Health,
    Puzzle,
    Key,
    Weapon,
    Ammo
};

ItemTypes itemType;
}

and I derived an Ammo subclass among others, which has an extra AmmoType enum. At some point in my inventory code, I have an AddToInventory(Item item) method that takes an Item and adds it to a playerInventory list.

I’m now trying to stack ammo instead of adding to a new slot, so I was intending to check if the item about to be added has the same AmmoType by running through the list. Something like this pseudocode:

void AddToInventory(Item item)
{
  foreach (Item i in playerInventory)
  {
    if ((Ammo)item.itemType == (Ammo)i.itemType)
    {
       // Stack bullets
    }
  }
}

Of course, it’s not possible to cast like this. Is there any other way to check for the argument’s properties, assuming it is of a certain subclass?

C# / Unity : how to use in a child class a variable created in a base class?

I’m just starting to learn C# and I have a very basic problem regarding classes and inheritance. Basically, I have created a Plant class the regroups the basic functionnalities of a plant, and then I created a Grass class that will be attached to a Grass object in my game.
And I wanted to be able to intialize some variables (like age or birthTime) in the Plant class, and then access them in the Grass class; like this, when I will create another type of plant (flower for example), I would not need to initialize these caracteristics.

Here is my Plant class, where I initialize the age and birthTime variables:

enter image description here

And here is my Grass class, where I would want to access these variables but I can’t to it… Could someone explain to me how to do it pls? Thanks!!

enter image description here

magento2 – How to add constant in core class ? and how to access that ? in magento 2

  1. create di.xml in to the following location

app/code/Vendor/Extension/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="MagentoCatalogModelCategory" type="VendorExtensionModelCategory" />
</config>
  1. create Category.php file on this location.

app/code/Vendor/Extension/Model/Category.php

namespace VendorExtensionModel;

class Category extends MagentoCatalogModelCategory
{
    const STATUS_PICKING = 'picking';

  public function __construct()
    {
        echo "Model Rewrite Working"; die();

    }
}

c++ – Reviewing my shader class for efficient use

Im just trying to setup my shader function in a class in a way that would make me work with it easier and in a more understandable way.

In Shader.h:

#pragma once
#include"Includes.h"
#include<unordered_map>

namespace GAME
{
    enum class Shader_Type
    {
        NONE = -1,
        VERTEX = 0,
        FRAGMENT = 1,
        GEOMETRY = 2
    };

    class Shader
    {
    private:
        std::map<Shader_Type, std::string>m_Data;
        Shader_Type type;
        std::unordered_map<std::string, int> m_UniformLocationCache;
    public:
        unsigned int Program_id;
    private:
        unsigned int Compiler(unsigned int type, const std::string& source);
        void Check_errors(unsigned int* id, unsigned int type);
        void Create_shader();

    public:

        Shader();
        ~Shader();

        Shader(const Shader& e);
        Shader& operator=(const Shader& e);
        Shader(Shader&& e)noexcept;
        Shader& operator=(Shader&& e)noexcept;
        Shader* operator-> () { return this; }

        operator Shader* () { return this; }
        Shader* Clone() { return new Shader(*this); }


        void Bind() const;
        void Unbind() const;

        void Reset();
        void Init(std::string vertexShader = "", std::string fragmentshader = "", std::string Geometryshader = "");

        unsigned int GetUniformLocation(const std::string& name);



        //uniforms

        void Setuniform1f(const std::string& name, float v1);
        void Setuniform2f(const std::string& name, float v1, float v2);
        void Setuniform3f(const std::string& name, float v1, float v2, float v3);
        void Setuniform4f(const std::string& name, float v1, float v2, float v3, float v4);

        void Setuniform1i(const std::string& name, int v1);
        void Setuniform2i(const std::string& name, int v1, int v2);
        void Setuniform3i(const std::string& name, int v1, int v2, int v3);
        void Setuniform4i(const std::string& name, int v1, int v2, int v3, int v4);

        void Setuniform1d(const std::string& name, double v1);
        void Setuniform2d(const std::string& name, double v1, double v2);
        void Setuniform3d(const std::string& name, double v1, double v2, double v3);
        void Setuniform4d(const std::string& name, double v1, double v2, double v3, double v4);



        void Setuniform1fv(const std::string& name, int count, glm::fvec1 v);
        void Setuniform2fv(const std::string& name, int count, glm::fvec2 v);
        void Setuniform3fv(const std::string& name, int count, glm::fvec3 v);
        void Setuniform4fv(const std::string& name, int count, glm::fvec4 v);

        void Setuniform1iv(const std::string& name, int count, glm::ivec1 v);
        void Setuniform2iv(const std::string& name, int count, glm::ivec2 v);
        void Setuniform3iv(const std::string& name, int count, glm::ivec3 v);
        void Setuniform4iv(const std::string& name, int count, glm::ivec4 v);

        void Setuniform1dv(const std::string& name, int count, glm::dvec1 v);
        void Setuniform2dv(const std::string& name, int count, glm::dvec2 v);
        void Setuniform3dv(const std::string& name, int count, glm::dvec3 v);
        void Setuniform4dv(const std::string& name, int count, glm::dvec4 v);



        void SetUniformMat2fv(const std::string& name, int count, GLboolean transpose, glm::mat2 value);
        void SetUniformMat3fv(const std::string& name, int count, GLboolean transpose, glm::mat3 value);
        void SetUniformMat4fv(const std::string& name, int count, GLboolean transpose, glm::mat4 value);



    };


}

#include"Includes.h" is the header where I kept all includes of gl and other required classes

In Shader.cpp:

#include "Shader.h"
namespace GAME
{
    Shader::Shader()
        :Program_id(0), type(Shader_Type::NONE)
    {
    }
    Shader::~Shader()
    {
    }

    Shader::Shader(const Shader& e)
    {
        this->m_Data = e.m_Data;
        this->m_UniformLocationCache = e.m_UniformLocationCache;
        this->Program_id = e.Program_id;
        this->type = Shader_Type(e.type);
    }

    Shader& Shader::operator=(const Shader& e)
    {
        this->m_Data = e.m_Data;
        this->m_UniformLocationCache = e.m_UniformLocationCache;
        this->Program_id = e.Program_id;
        this->type = Shader_Type(e.type);
        return *this;
    }

    Shader::Shader(Shader&& e) noexcept
    {
        this->m_Data = std::move(e.m_Data);
        this->m_UniformLocationCache = std::move(e.m_UniformLocationCache);
        this->Program_id =std::move( e.Program_id);
        this->type = std::move(Shader_Type(e.type));
    }

    Shader& Shader::operator=(Shader&& e) noexcept
    {
        this->m_Data = std::move(e.m_Data);
        this->m_UniformLocationCache = std::move(e.m_UniformLocationCache);
        this->Program_id = std::move(e.Program_id);
        this->type = std::move(Shader_Type(e.type));
        return *this;
    }

    void Shader::Bind() const
    {
        glUseProgram(Program_id);
    }
    void Shader::Unbind() const
    {
        glUseProgram(0);
    }


    void Shader::Reset()
    {
        this->type = Shader_Type::NONE;
        this->Program_id = 0;
        this->m_UniformLocationCache.clear();
        this->m_Data.clear();
    }
    void Shader::Init(std::string vertexShader, std::string fragmentshader, std::string Geometryshader)
    {
        m_Data(Shader_Type::VERTEX) = vertexShader;
        m_Data(Shader_Type::FRAGMENT) = fragmentshader;
        m_Data(Shader_Type::GEOMETRY) = Geometryshader;

        Create_shader();
        Unbind();
    }

    unsigned int Shader::GetUniformLocation(const std::string& name)
    {
        if (m_UniformLocationCache.find(name) != m_UniformLocationCache.end())
        {
            return m_UniformLocationCache(name);
        }
        int location = glGetUniformLocation(Program_id, name.c_str());
        if (location == -1)
        {
            std::cout << "Warning! Uniform " << name << " is unused or not found or does no exist!" << std::endl;
        }
        else
            m_UniformLocationCache(name) = location;
        return location;
    }

    void Shader::Create_shader()
    {
        Program_id = glCreateProgram();

        if (m_Data(Shader_Type::VERTEX) != "")
        {
            unsigned int vs = Compiler(GL_VERTEX_SHADER, m_Data(Shader_Type::VERTEX));
            glAttachShader(Program_id, vs);
            glDeleteShader(vs);
        }
        if (m_Data(Shader_Type::FRAGMENT) != "")
        {
            unsigned int fs = Compiler(GL_FRAGMENT_SHADER, m_Data(Shader_Type::FRAGMENT));
            glAttachShader(Program_id, fs);
            glDeleteShader(fs);
        }
        if (m_Data(Shader_Type::GEOMETRY) != "")
        {
            unsigned int gs = Compiler(GL_GEOMETRY_SHADER, m_Data(Shader_Type::GEOMETRY));
            glAttachShader(Program_id, gs);
            glDeleteShader(gs);
        }

        glLinkProgram(Program_id);
        glValidateProgram(Program_id);

    }

    unsigned int Shader::Compiler(unsigned int type, const std::string& source)
    {
        unsigned int id = glCreateShader(type);
        const char* src = source.c_str();
        glShaderSource(id, 1, &src, nullptr);
        glCompileShader(id);

        Check_errors(&id, type);

        return id;
    }

    void Shader::Check_errors(unsigned int* id, unsigned int type)
    {
        int result;
        glGetShaderiv(*id, GL_COMPILE_STATUS, &result);
        if (result == GL_FALSE)
        {
            int length;
            glGetShaderiv(*id, GL_INFO_LOG_LENGTH, &length);
            char* message = (char*)alloca(length * sizeof(char));
            glGetShaderInfoLog(*id, length, &length, message);
            std::cout << "Failed to compile ";
            switch (type)
            {
            case GL_VERTEX_SHADER:
                std::cout << "vertex";
                break;
            case GL_FRAGMENT_SHADER:
                std::cout << "fragment";
                break;
            case GL_GEOMETRY_SHADER:
                std::cout << "geometry";
                break;
            default:
                std::cout << "unknown";
                break;
            }
            std::cout << " shader!" << std::endl;
            std::cout << " Error:" << message << std::endl;
            glDeleteShader(*id);
            id = 0;
        }

    }





    void Shader::Setuniform1f(const std::string& name, float v1)
    {
        glUniform1f(GetUniformLocation(name), v1);
    }
    void Shader::Setuniform2f(const std::string& name, float v1, float v2)
    {
        glUniform2f(GetUniformLocation(name), v1, v2);
    }
    void Shader::Setuniform3f(const std::string& name, float v1, float v2, float v3)
    {
        glUniform3f(GetUniformLocation(name), v1, v2, v3);
    }
    void Shader::Setuniform4f(const std::string& name, float v1, float v2, float v3, float v4)
    {
        glUniform4f(GetUniformLocation(name), v1, v2, v3, v4);
    }

    void Shader::Setuniform1i(const std::string& name, int v1)
    {
        glUniform1i(GetUniformLocation(name), v1);
    }
    void Shader::Setuniform2i(const std::string& name, int v1, int v2)
    {
        glUniform2i(GetUniformLocation(name), v1, v2);
    }
    void Shader::Setuniform3i(const std::string& name, int v1, int v2, int v3)
    {
        glUniform3i(GetUniformLocation(name), v1, v2, v3);
    }
    void Shader::Setuniform4i(const std::string& name, int v1, int v2, int v3, int v4)
    {
        glUniform4i(GetUniformLocation(name), v1, v2, v3, v4);
    }

    void Shader::Setuniform1d(const std::string& name, double v1)
    {
        glUniform1d(GetUniformLocation(name), v1);
    }
    void Shader::Setuniform2d(const std::string& name, double v1, double v2)
    {
        glUniform2d(GetUniformLocation(name), v1, v2);
    }
    void Shader::Setuniform3d(const std::string& name, double v1, double v2, double v3)
    {
        glUniform3d(GetUniformLocation(name), v1, v2, v3);
    }
    void Shader::Setuniform4d(const std::string& name, double v1, double v2, double v3, double v4)
    {
        glUniform4d(GetUniformLocation(name), v1, v2, v3, v4);
    }

    void Shader::Setuniform1fv(const std::string& name, int count, glm::fvec1 v)
    {
        glUniform1fv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform2fv(const std::string& name, int count, glm::fvec2 v)
    {
        glUniform2fv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform3fv(const std::string& name, int count, glm::fvec3 v)
    {
        glUniform3fv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform4fv(const std::string& name, int count, glm::fvec4 v)
    {
        glUniform4fv(GetUniformLocation(name), count, &v(0));
    }

    void Shader::Setuniform1iv(const std::string& name, int count, glm::ivec1 v)
    {
        glUniform1iv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform2iv(const std::string& name, int count, glm::ivec2 v)
    {
        glUniform2iv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform3iv(const std::string& name, int count, glm::ivec3 v)
    {
        glUniform3iv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform4iv(const std::string& name, int count, glm::ivec4 v)
    {
        glUniform4iv(GetUniformLocation(name), count, &v(0));
    }

    void Shader::Setuniform1dv(const std::string& name, int count, glm::dvec1 v)
    {
        glUniform1dv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform2dv(const std::string& name, int count, glm::dvec2 v)
    {
        glUniform2dv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform3dv(const std::string& name, int count, glm::dvec3 v)
    {
        glUniform3dv(GetUniformLocation(name), count, &v(0));
    }
    void Shader::Setuniform4dv(const std::string& name, int count, glm::dvec4 v)
    {
        glUniform4dv(GetUniformLocation(name), count, &v(0));
    }

    void Shader::SetUniformMat2fv(const std::string& name, int count, GLboolean transpose, glm::mat2 value)
    {
        glUniformMatrix2fv(GetUniformLocation(name), count, transpose, &value(0)(0));
    }
    void Shader::SetUniformMat3fv(const std::string& name, int count, GLboolean transpose, glm::mat3 value)
    {
        glUniformMatrix3fv(GetUniformLocation(name), count, transpose, &value(0)(0));
    }
    void Shader::SetUniformMat4fv(const std::string& name, int count, GLboolean transpose, glm::mat4 value)
    {
        glUniformMatrix4fv(GetUniformLocation(name), count, transpose, &value(0)(0));
    }

}

Is this enough for using in normal programming or do i need to make some changes to make it more usable and efficient? Any helpful review would be appreciated. Thanks in advance!!

class – Why does Protobuf generate outer classes for Java?

I googled this and found questions like How to use Protobuf message as java class without a java outer class? which talk about how one might tweak their Protobuf Java code generation. For example, that person wants to avoid having outer classes. The answer tells them about the “multiple files” option.

But I’d like to know why the Java generated code, by default, is split up this way. I didn’t notice code split up like that when I used my same Protobuf files to generate Go code. I got just one struct per Protobuf message I defined. In Java, I get two classes per Protobuf message defined, and I can choose between them being nested or in separate files. Why?

class diagram – Confuse over qualification association in conceptual schema UML

I am getting confused at qualification association. I perform qualification when I need to remove many-to-many relationship or when the PK of a particular table is not able to be uniquely identify a row – in this case I make a composite key by qualifying it.

That said, I do not understand whether after performing a qualification, will the relationship becomes one-to-many or one-to-one. Some of my friends said that after qualification, it is always a one-to-many relationship but after reading some sites, it says qualification reduce the multiplicity. This particular sentence from a few websites confused me:

qualification reduces the multiplicity at the target end of the association, usually down from many to one, because it implies the selection of usually one instance from a larger set.

Given the below simple conceptual schema

enter image description here

In this case, will this consider a one-to-one relationship or a one-to-many relationship?

java – Would an array and a custom node class have same memory intake?

There was recently a question on my exam where we were supposed to choose will the 2 (arr or x) take up same space in memory or would they take up different amount of memory space?

They are defined as follows

class Node{
    int a, b;
    Node(int a,int b) {
        this.a = a; this.b = b;
    }
}
public static void main(String() args) {
    Node x=new Node(2,3);
    int arr()=new arr(2);
}

Now my reasoning was that since arr and x are implemented differently they’ll have different memory consumption as arr must have some additional meta data too apart from these integers. I tried to verify this using Java functions which monitor memory but since I’m new to Java I couldn’t really grasp how to do it. How do I check this and which one of them will have take up more space in memory?

c++11 – template Matrix class with Static or dynamic size

I started implementing the folowing Matrix class in order to get a better understanding of templates classes in general. For now, it lacks a lot of features, it does very basic things:

  • addition
  • multiplication (only matrix X matrix multiplication is available here)
  • transpose
  • conversion to a string

Here are some points i think might be interesting

  • The dimensions of the matrices can either be “static” or “dynamic”. By static, i mean the number of rows / columns is not allowed to change even if the data is stored in an std::vector

  • When adding two matrices together, the resulting matrix’s dimension is static if at least one of the two operands is static.

  • When multiplying two matrices together, the resulting matrix’s dimension depends on the rows of the left hand side and the columns of the right hand side of the “*”.

  • The type of data contained in the returned matrix corresponds to the implicit cast of the types of the left and right sides of the expression. If the user decided to multiply a matrix of Foos, with a matrix of Bars, it’s on him.

  • The “changeSize” methode, when called on a static matrix will only throw if the requested change is different from the matrix size.

  • I did not bother for now with the type of exception i used as this is more of an exercise than something that i will use in a real application.

  • The reason i made it possible to instanciate Static or dynamic matrices is because i want it to be able to manage Vector X Matrix operations. As a vector is just a special case of matrices, i choose to made them into a single class. (in the style of Eigen, which my code is inspired from a used inteface point of view).

Is my use of the rvalues references and move semantics correct? (that is a notion i learned about last week, any advice can help)

What do you think could be improved about my code?

Is there any notion i should learn before continuing?

Were any design choices in terme of template parameters good or bad?

#ifndef UTILS_MATRIX_H_
#define UTILS_MATRIX_H_

#include <vector>
#include <stdexcept>
#include <sstream>
#include <iomanip>

namespace mat
{

  constexpr size_t DYNAMIC = static_cast<size_t>(-1); // (-) No matrix can be of this size... right?

  template<typename TYPE, size_t NBROWS, size_t NBCOLS>
  class Matrix
  {
    private:

      std::vector<std::vector<TYPE>> matrixData;             // (-) Contents of the Matrix as a 2D array
      static constexpr bool isRowStatic = NBROWS != DYNAMIC; // (-) Is the number of rows of this matrix editable at run time
      static constexpr bool isColStatic = NBCOLS != DYNAMIC; // (-) Is the number of columns of this matrix editable at run time

    public:

      /** @brief Default constructor
       *
       *  @return Void.
       */
      Matrix() :
          matrixData()
      {
        if ((NBROWS <= 0 and NBROWS != DYNAMIC) or (NBCOLS <= 0 and NBCOLS != DYNAMIC))
          throw std::runtime_error("The number of rows and columns of a static matrix must be positive integers");

        // In case of a dynamic shape, the matrix should not be instanciated
        if(isRowStatic and isColStatic)
          internalChangeSize(NBROWS, NBCOLS);
      }

      /** @brief Consutuctor for the static size matrix
       *  @param i_DefaultValue IN : Default value used to fill
       *         the matrix
       *
       *  @return Void.
       */
      Matrix(const TYPE &i_DefaultValue) :
          matrixData()
      {
        // error handling
        if (not isRowStatic or not isColStatic)
          throw std::runtime_error("The default value constructor can not be called on a Matrix with at least one dynamic component");

        if ((NBROWS <= 0 and NBROWS != DYNAMIC) or (NBCOLS <= 0 and NBCOLS != DYNAMIC))
          throw std::runtime_error("The number of rows and columns of a static matrix must be positive integers");

        internalChangeSize(NBROWS, NBCOLS, i_DefaultValue);
      }

      /** @brief Consutuctor for the dynamic size matrix without default value
       *
       *  @param i_Nbrows       IN : Number of rows of the matrix
       *  @param i_Nbcols       IN : Number of columns of the matrix
       *
       *  @return Void.
       */
      Matrix(const size_t i_Nbrows,
             const size_t i_Nbcols) :
          matrixData()
      {
        // error handling
        if (i_Nbrows <= 0 or i_Nbcols <= 0)
          throw std::runtime_error("The number or rows and columns has to be a positive integer");

        // If one dimension is static, ignore the related constructor parameters
        size_t NbRows = i_Nbrows;
        size_t NbCols = i_Nbcols;
        if(isRowStatic)
          NbRows = NBROWS;
        if(isColStatic)
          NbCols = NBCOLS;

        internalChangeSize(NbRows, NbCols, TYPE());
      }

      /** @brief Consutuctor for the dynamic size matrix with default value
       *
       *  @param i_Nbrows       IN : Number of rows of the matrix
       *  @param i_Nbcols       IN : Number of columns of the matrix
       *  @param i_DefaultValue IN : Default value used to fill the
       *                             matrix
       *
       *  @return Void.
       */
      Matrix(const size_t i_Nbrows,
             const size_t i_Nbcols,
             const TYPE &i_DefaultValue) :
          matrixData()
      {
        // error handling
        if (i_Nbrows <= 0 or i_Nbcols <= 0)
          throw std::runtime_error("The number or rows and columns has to be a positive integer");

        // If one dimension is static, ignore the related constructor parameters
        size_t NbRows = i_Nbrows;
        size_t NbCols = i_Nbcols;
        if(isRowStatic)
          NbRows = NBROWS;
        if(isColStatic)
          NbCols = NBCOLS;

        internalChangeSize(NbRows, NbCols, i_DefaultValue);
      }

      /** @brief Copy constructor
       *
       *  @param i_otherMatrix IN : Matrix to be copied
       *
       *  @return Void.
       */
      Matrix(const Matrix<TYPE, NBROWS, NBCOLS>& i_otherMatrix):
          matrixData()
      {
        if(not i_otherMatrix.isEmpty())
          {
          changeSize(i_otherMatrix.getNbRows(), i_otherMatrix.getNbCols());
          matrixData = i_otherMatrix.matrixData;
          }
      }

      /** @brief Move constructor
       *
       *  @param i_otherMatrix IN : Matrix to be moved
       *
       *  @return Void.
       */
      Matrix(Matrix<TYPE, NBROWS, NBCOLS>&& i_otherMatrix):
          matrixData()
      {
        matrixData = std::move(i_otherMatrix.matrixData);
      }

      /** @brief getter for the matrix data vector
       *
       *  @return std::vector<std::vector<TYPE>>&.
       */
      const std::vector<std::vector<TYPE>>& getMatrixData() const
      {
        return matrixData;
      }

      /** @brief getter for the number or rows
       *
       *  @return size_t
       */
      size_t getNbRows() const
      {
        return matrixData.size();
      }

      /** @brief getter for the number or columns
        *
        *  @return size_t
        */
      size_t getNbCols() const
      {
        if(matrixData.size() > 0)
          return matrixData(0).size();
        else
          return 0;
      }

      /** @brief is the Matrix is empty
        *
        *  @return bool
        */
      bool isEmpty() const
      {
        return getNbRows() == 0 or getNbCols() == 0;
      }

      /** @brief function used to retrieve the shape of the matrix
       *  @param o_NbRows OUT : Number of rows of the matrix
       *  @param o_NbCols OUT : Number of columns of the matrix
       *
       *  @return Void.
       */
      std::pair<size_t, size_t> shape() const
      {
        return std::pair<size_t, size_t>(getNbRows(), getNbCols());
      }

      /** @brief function used to print the contents of the
       *         matrix formatted into a string
       *
       *  @return std::string
       */
      std::string toString(int i_Precision = 10) const
      {
        std::ostringstream SS;

        // if 0 lines representation is an empty bracket
        if(matrixData.size() == 0)
          SS << "| |" << std::endl;

        // This will align the floating point numbers
        SS << std::showpoint;
        SS << std::setprecision(i_Precision);
        for(auto& Row : matrixData)
        {
          SS << "|";
          for(auto& Value : Row)
          {
            SS << " " << Value << " ";
          }
          SS << "|" << std::endl;
        }
        return SS.str();
      }

      /** @brief function used to change the size of the matrix
       *         This method does not require a default value,
       *         hence it is default initialized
       *
       *  @param i_NbRows IN : New number of rows of the matrix
       *  @param o_NbCols IN : New number of columns of the matrix
       *
       *  @return Void.
       */
      void changeSize(const size_t i_NbRows, const size_t i_NbCols)
      {
        // Error handling
        if (i_NbRows <= 0 or i_NbCols <= 0)
          throw std::runtime_error("The number or rows and columns has to be a positive integer");

        if (isRowStatic and NBROWS != i_NbRows)
          throw std::runtime_error("You cannot change the number of rows, the matrix row size is static.");

        if(isColStatic and NBCOLS != i_NbCols)
          throw std::runtime_error("You cannot change the number of columns, the matrix columns size is static.");

        internalChangeSize(i_NbRows, i_NbCols);
      }

      /** @brief function used to change the size of the matrix
       *         This method does not require a default value,
       *         hence it is default initialized
       *
       *  @param i_NewShape IN : New shape of the matrix
       *
       *  @return Void.
       */
      void changeSize(const std::pair<size_t, size_t>& i_NewShape)
      {
        changeSize(i_NewShape.first, i_NewShape.second);
      }

      /** @brief function used to change the size of the matrix
       *         This method requires a default value for filling
       *         any new row / column.
       *
       *  @param i_NbRows     IN : New number of rows of the matrix
       *  @param o_NbCols     IN : New number of columns of the matrix
       *  @param DefaultValue IN : Default value used to fill the matrix
       *
       *  @return Void.
       */
      void changeSize(const size_t i_NbRows, const size_t i_NbCols, const TYPE &DefaultValue)
      {
        // error handling
        if (i_NbRows <= 0 or i_NbCols <= 0)
          throw std::runtime_error("The number or rows and columns has to be a positive integer");

        if (isRowStatic and NBROWS != i_NbRows)
          throw std::runtime_error("You cannot change the number of rows, the matrix columns size is static.");

        if(isColStatic and NBCOLS != i_NbCols)
          throw std::runtime_error("You cannot change the number of columns, the matrix columns size is static.");

        internalChangeSize(i_NbRows, i_NbCols, DefaultValue);
      }

      /** @brief function used to change the size of the matrix
       *         This method requires a default value for filling
       *         any new row / column.
       *
       *  @param i_NewShape   IN : New shape of the matrix
       *  @param DefaultValue IN : Default value used to fill the matrix
       *
       *  @return Void.
       */
      void changeSize(const std::pair<size_t, size_t>& i_NewShape, const TYPE &DefaultValue)
      {

        changeSize(i_NewShape.first, i_NewShape.second, DefaultValue);
      }

      /** @brief function used to transpose the current matrix.
       *         If the matrix is dynamically allocated, it's shape
       *         might be changed by the function
       *
       *  @return Void.
       */
      void transpose()
      {
        // Error handlingmatrixData
        if (isEmpty())
          throw std::runtime_error("The transpose function can not be called on an empty matrix");

        if ((isRowStatic or isColStatic) and getNbRows() != getNbCols())
          throw std::runtime_error("The transpose function can not be called on a non square matrix with at least one static component");

        // The transposed Matrix is built and replaces the old data
        std::vector<std::vector<TYPE>> newData(getNbCols(), std::vector<TYPE>(getNbRows(), (*this)(0,0)));

        for (size_t i = 0 ; i < getNbCols() ; i += 1)
          for (size_t j = 0 ; j < getNbRows() ; j += 1)
            newData(i)(j) = (*this)(i,j);

        matrixData = std::move(newData);
      }

      /** @brief () operator. returns a reference to
       *         the value at row i, column j
       *
       *  @return const TYPE&
       */
      const TYPE& operator()(size_t i_Row, size_t i_Col) const
      {
        try
        {
          return matrixData.at(i_Row).at(i_Col);
        }
        catch(std::out_of_range& e)
        {
          const auto MatrixShape = this->shape();
          std::ostringstream SS;
          SS << "Indexes : (" << i_Row << ", " << i_Col << ") are out of bounds of the Matrix : " << "(" << MatrixShape.first << ", " << MatrixShape.second << ")";
          throw std::runtime_error(SS.str());
        }
      }

      /** @brief () operator. returns a reference to
       *         the value at row i, column j
       *
       *  @return const TYPE&
       */
      TYPE& operator()(size_t i_Row, size_t i_Col)
      {
        try
        {
          return matrixData.at(i_Row).at(i_Col);
        }
        catch(std::out_of_range& e)
        {
          const auto MatrixShape = this->shape();
          std::ostringstream SS;
          SS << "Indexes : (" << i_Row << ", " << i_Col << ") are out of bounds of the Matrix : " << "(" << MatrixShape.first << ", " << MatrixShape.second << ")";
          throw std::runtime_error(SS.str());
        }
      }

      /** @brief = operator. It copies the right hand side
       *         into the left hand size Matrix. If the sizes are
       *         different and the left hand side is static, the copy
       *         fails
       *  @param rhs  IN : Right hand side matrix
       *
       *  @return Void.
       */
      template<typename RHSTYPE, size_t RHSNBROWS, size_t RHSNBCOLS>
      Matrix<TYPE, NBROWS, NBCOLS>& operator=(const Matrix<RHSTYPE, RHSNBROWS, RHSNBCOLS> &rhs)
      {
        const auto LhsShape = this->shape();
        const auto RhsShape = rhs.shape();

        // Error handling
        if ((isRowStatic and (this->getNbRows() != rhs.getNbRows())) or
            (isColStatic and (this->getNbCols() != rhs.getNbCols())))
        {
          std::ostringstream SS;
          SS << "Impossible to fit data from a matrix of size (" << rhs.getNbRows() << ", " << rhs.getNbCols() << ") into"
                " a static matrix of size (" << this->getNbRows() << ", " << this->getNbCols() << ")";
          throw std::runtime_error(SS.str());
        }

        // If both matrices are empty, we dont need to do anything
        if(not(isEmpty() and rhs.isEmpty()))
        {
          // else, change the size only if necessary, taking a default value in one of the non empty matrices in order not to call the default constructor
          if (LhsShape != RhsShape )
          {
            if(not isEmpty())
            {
              changeSize(RhsShape, (*this)(0,0));
            }
            else if(not rhs.isEmpty())
            {
              changeSize(RhsShape, rhs(0,0));
            }
          }
        }

        matrixData = rhs.getMatrixData();
        return *this;
      }

      /** @brief move = operator. It moves the right hand side
       *         into the left hand size Matrix. If the sizes are
       *         different and the left hand side is static, the copy
       *         fails
       *  @param rhs  IN : Right hand side matrix
       *
       *  @return Void.
       */
      template<typename RHSTYPE, size_t RHSNBROWS, size_t RHSNBCOLS>
      Matrix<TYPE, NBROWS, NBCOLS>& operator=(Matrix<RHSTYPE, RHSNBROWS, RHSNBCOLS>&& rhs)
      {
        const auto LhsShape = this->shape();
        const auto RhsShape = rhs.shape();

        // Error handling
        if ((isRowStatic and (this->getNbRows() != rhs.getNbRows())) or
            (isColStatic and (this->getNbCols() != rhs.getNbCols())))
        {
          std::ostringstream SS;
          SS << "Impossible to fit data from a matrix of size (" << rhs.getNbRows() << ", " << rhs.getNbCols() << ") into"
                " a static matrix of size (" << this->getNbRows() << ", " << this->getNbCols() << ")";
          throw std::runtime_error(SS.str());
        }

        // If both matrices are empty, we dont need to resize anything
        if(not(isEmpty() and rhs.isEmpty()))
        {
          // else, change the size only if necessary, taking a default value in one of the non empty matrices in order not to call the default constructor
          if (LhsShape != RhsShape )
          {
            if(not isEmpty())
            {
              changeSize(RhsShape, (*this)(0,0));
            }
            else if(not rhs.isEmpty())
            {
              changeSize(RhsShape, rhs(0,0));
            }
          }
        }

        matrixData = std::move(rhs.matrixData);
        return *this;
      }

      /** @brief += operator. It adds the right hand side
       *         into the left hand size Matrix. If the sizes are
       *         different the operator fails
       *
       *  @param i_NbRows  IN : New number of rows of the matrix
       *  @param o_NbCols  IN : New number of columns of the matrix
       *  @param io_Matrix IN : Matrix which size will be reduced
       *
       *  @return Void.
       */
      template<typename RHSTYPE, size_t RHSNBROWS, size_t RHSNBCOLS>
      Matrix<TYPE, NBROWS, NBCOLS>& operator+=(const Matrix<RHSTYPE, RHSNBROWS, RHSNBCOLS> &rhs)
      {
        // Error handling
        if(this->isEmpty() or rhs.isEmpty())
          throw std::runtime_error("Adding empty matrices is forbidden");

        if (rhs.shape() != this->shape())
          throw std::runtime_error("Adding matrices of different shapes is forbidden");

        for(size_t i = 0; i < getNbRows()  ; i += 1)
          for(size_t j = 0 ; j < getNbCols() ; j += 1)
            matrixData(i)(j) += rhs(i,j);

        return *this;
      }


      /** @brief + operator. It adds both sides of the "+" sign
       *         and returns a static size matrix. Both sides
       *         have to be of the same shape, otherwise the
       *         operator fails.
       *
       *  @param rhs IN : Matrix, right side of the equation
       *
       *  @return Matrix<decltype(rhs(0,0) + (*this)(0,0)), NBROWS, NBCOLS, true>.
       */
      template<typename LHSTYPE, size_t LHSNBROWS, size_t LHSNBCOLS, typename RHSTYPE, size_t RHSNBROWS, size_t RHSNBCOLS>
      friend auto operator+(const Matrix<LHSTYPE, LHSNBROWS, LHSNBCOLS> &lhs, const Matrix<RHSTYPE, RHSNBROWS, RHSNBCOLS> &rhs) ->
             Matrix<decltype(lhs(0,0) + rhs(0,0)), LHSNBROWS == DYNAMIC ? RHSNBROWS : DYNAMIC,
                                                   LHSNBCOLS == DYNAMIC ? RHSNBCOLS : DYNAMIC>;

      /** @brief operator* It multiplies both sides of the "*" sign
       *         and returns a static size matrix. Both sides
       *         have to have compatible sizes, (lhs.columns == rhs.cols)
       *         otherwise, the operator fails.
       *
       *  @param rhs IN : Matrix, right side of the equation
       *
       *  @return Matrix<decltype(rhs(0,0) * (*this)(0,0)), this->getNbRows(), rhs.getNbCols(), true>
       */
      template<typename LHSTYPE, size_t LHSNBROWS, size_t LHSNBCOLS, typename RHSTYPE, size_t RHSNBROWS, size_t RHSNBCOLS>
      friend auto operator*(const Matrix<LHSTYPE, LHSNBROWS, LHSNBCOLS> &lhs, const Matrix<RHSTYPE, RHSNBROWS, RHSNBCOLS> &rhs) -> Matrix<decltype(rhs(0,0) * lhs(0,0)), LHSNBROWS, RHSNBCOLS>;


    private:
      /** @brief function used to change the size of the matrix
       *         This method does not require a default value,
       *         hence it is default initialized. It does not check if the matrix is static or not
       *
       *  @param i_NbRows IN : New number of rows of the matrix
       *  @param o_NbCols IN : New number of columns of the matrix
       *
       *  @return Void.
       */
      void internalChangeSize(const size_t i_NbRows, const size_t i_NbCols)
      {
        // Error handling
        if (i_NbRows <= 0 or i_NbCols <= 0)
          throw std::runtime_error("The number or rows and columns should be a positive integer");

        matrixData.resize(i_NbRows, std::vector<TYPE>(i_NbCols, TYPE()));
        for (auto& row : matrixData)
          row.resize(i_NbCols, TYPE());
      }

      /** @brief function used to change the size of the matrix
       *         This method requires a default value for filling
       *         any new row / column. It does not check if the matrix is static or not
       *
       *  @param i_NbRows     IN : New number of rows of the matrix
       *  @param o_NbCols     IN : New number of columns of the matrix
       *  @param DefaultValue IN : Default value used to fill the matrix
       *
       *  @return Void.
       */
      void internalChangeSize(const size_t i_NbRows, const size_t i_NbCols, const TYPE &DefaultValue)
      {
        // error handling
        if (i_NbRows <= 0 or i_NbCols <= 0)
          throw std::runtime_error("The number or rows and columns has to be a positive integer");

        matrixData.resize(i_NbRows, std::vector<TYPE>(i_NbCols, DefaultValue));
        for (auto& row : matrixData)
          row.resize(i_NbCols, DefaultValue);
      }
    };

  /** @brief + operator. It adds both sides of the "+" sign
   *         and returns a static size matrix. Both sides
   *         have to be of the same shape, otherwise the
   *         operator fails.
   *
   *  @param rhs IN : Matrix, right side of the equation
   *
   *  @return Matrix<decltype(rhs(0,0) + (*this)(0,0)), NBROWS, NBCOLS, true>.
   */
  template<typename LHSTYPE, size_t LHSNBROWS, size_t LHSNBCOLS, typename RHSTYPE, size_t RHSNBROWS, size_t RHSNBCOLS>
    auto operator+(const Matrix<LHSTYPE, LHSNBROWS, LHSNBCOLS> &lhs, const Matrix<RHSTYPE, RHSNBROWS, RHSNBCOLS> &rhs) ->
      Matrix<decltype(lhs(0,0) + rhs(0,0)), LHSNBROWS == DYNAMIC ? RHSNBROWS : DYNAMIC,
                                            LHSNBCOLS == DYNAMIC ? RHSNBCOLS : DYNAMIC>
    {
      // Error handling
      if(lhs.isEmpty() or rhs.isEmpty())
        throw std::runtime_error("Adding empty matrices is forbidden");

      if (rhs.shape() != lhs.shape())
        throw std::runtime_error("Adding matrices of different shapes is forbidden");

      Matrix<decltype(lhs(0,0) + rhs(0,0)), LHSNBROWS == DYNAMIC ? RHSNBROWS : DYNAMIC,
                                            LHSNBCOLS == DYNAMIC ? RHSNBCOLS : DYNAMIC> newMatrix(lhs.getNbRows(), lhs.getNbCols(), lhs(0,0));

      for(size_t i = 0 ; i < rhs.getNbRows() ; i += 1)
        for(size_t j = 0 ; j < rhs.getNbCols() ; j += 1)
          newMatrix(i, j) = lhs(i,j) + rhs(i,j);

      return newMatrix;
    }

  /** @brief operator* It multiplies both sides of the "*" sign
   *         and returns a static size matrix. Both sides
   *         have to have compatible sizes, (lhs.columns == rhs.cols)
   *         otherwise, the operator fails.
   *
   *  @param rhs IN : Matrix, right side of the equation
   *
   *  @return Matrix<decltype(rhs(0,0) * (*this)(0,0)), this->getNbRows(), rhs.getNbCols(), true>
   */
  template<typename LHSTYPE, size_t LHSNBROWS, size_t LHSNBCOLS, typename RHSTYPE, size_t RHSNBROWS, size_t RHSNBCOLS>
  auto operator*(const Matrix<LHSTYPE, LHSNBROWS, LHSNBCOLS> &lhs, const Matrix<RHSTYPE, RHSNBROWS, RHSNBCOLS> &rhs) -> Matrix<decltype(rhs(0,0) * lhs(0,0)), LHSNBROWS, RHSNBCOLS>
  {
    // error handling
    if(lhs.isEmpty() or rhs.isEmpty())
      throw std::runtime_error("Multiplying empty matrices is forbidden");

    if(lhs.getNbCols() != rhs.getNbRows())
      throw std::runtime_error("The size of the matrices is incompatible with matrix multiplication");

    Matrix<decltype(rhs(0,0) * lhs(0,0)), LHSNBROWS, RHSNBCOLS> newMatrix(lhs.getNbRows(), rhs.getNbCols(), lhs(0,0));

    for(size_t i = 0 ; i < lhs.getNbRows() ; i += 1)
    {
      for(size_t j = 0 ; j < rhs.getNbCols(); j += 1)
      {
        decltype(rhs(0,0) * lhs(0,0)) sum = lhs(i,0) * rhs(0,j); // Compute the first element of the sum in order not to call the default constructor
        for(size_t k = 1 ; k < lhs.getNbRows() ; k += 1)
        {
          sum += lhs(i,k) * rhs(k,j);
        }
        newMatrix(i, j) = std::move(sum);
      }
    }
    return newMatrix;
  }

  /** @brief operator<< outputs the Matrix into a stream
   *
   *  @param i_Matrix IN  : Matrix to output
   *  @param o_OS     OUT : Stream in which the matrix must be fitted
   *
   *  @return std::ostream&
   */
  template <typename TYPE, size_t NBROWS, size_t NBCOLS>
  std::ostream& operator<<(std::ostream& o_OS, const Matrix<TYPE, NBROWS, NBCOLS>& i_Matrix)
  {
      return o_OS << i_Matrix.toString();
  }
} /* namespace Mat */

c# – Access abstract class members from childs inherits

I have an abstract class called Flight and its implement a interface called IFlight and it has a virtual method, another three classes that inherit from it, the only diffrence between those three classes is the implemantation of this method. Another thing that I want to do is implement a method that accepts as an argument an object of type IFlight (could be one of those three classes) and from them i want to access the members of the abstract class (Flight). Which way there is to implement such thing ?

Flight:

class AbsFlight: IFlight
{ 
    public int ID { get; set; }

    public string Start_Point { get; set; }

    public virtual float Calculate_Price(float Base_Price)
    {
        return Base_Price;
    } 
}

One of the classes (The other two looks similar except the method “Calculate_Price”):

class Charter: AbsFlight
{
    public override float Calculate_Price(float Base_Price)
    {
        return base.Calculate_Price(Base_Price) * 3;
    }
}

Main:

    private static void Some_Method(IFlight flight)
    {
        Console.WriteLine(flight.Calculate_Price(2)); //OK
        Console.WriteLine(flight.ID); //Error
    }

    static void Main(string() args)
    {
        List<IFlight> flights = new List<IFlight>();

        flights.Add(new Regular());
        flights.Add(new Charter());
        flights.Add(new LowCost());

        Print_Variables(flights(0));

        Console.WriteLine(Main_Calc(flights(0)));
    }