- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个 .dll 文件。我定义一个类
class Contactmodel
public:
Contactmodel();
virtual ~Contactmodel();
然后,我尝试创建这个类的一个实例
virtual Contactmodel *clone() const {return new Contactmodel();}
但是编译的时候报错:object of abstract class type is not allowed when create an instance of a abstract class
你能告诉我创建实例时我做错了什么以及如何修复它吗?谢谢你!
我的头文件
#pragma once
// contactmodelCohesive.h
#include "contactmodel/src/contactmodelmechanical.h"
#ifdef Cohesive_LIB
# define Cohesive_EXPORT EXPORT_TAG
#elif defined(NO_MODEL_IMPORT)
# define Cohesive_EXPORT
#else
# define Cohesive_EXPORT IMPORT_TAG
#endif
namespace cmodelsxd {
using namespace itasca;
class ContactModelCohesive : public ContactModelMechanical {
public:
Cohesive_EXPORT ContactModelCohesive();
Cohesive_EXPORT virtual ~ContactModelCohesive();
virtual void copy(const ContactModel *c);
virtual void archive(ArchiveStream &);
virtual QString getName() const { return "Cohesive"; }
virtual void setIndex(int i) { index_=i;}
virtual int getIndex() const {return index_;}
enum PropertyKeys {
kwKn=1
, kwKs
, kwFric
, kwForce
, kwMoment
, kwState
, kwRGap
, kwConRad
, kwSig
, kwTau
, kwEmod
, kwKRatio
, kwTenStrength
, kwCoh
, kwPhiF
, kwPhiD
, kwInelasDeform
, kwDamagevar
, kwAlpha
, kwLamda
, kwwsig
, kwwcoh
};
virtual QString getProperties() const {
return " kn"
",ks"
",fric"
",coh_force"
",coh_moment"
",state"
",rgap"
",con_rad"
",sigma"
",tau"
",emod"
",kratio"
",ten_strength"
",cohesion"
",phi_f"
",phi_d"
",in_deform"
",D_var"
",alpha"
",lamda"
",w_sig"
",w_coh";
}
enum FishCallEvents { fActivated=0, fBondBreak };
virtual QString getFishCallEvents() const { return "contact_activated,contact_break"; }
virtual QVariant getProperty(uint i,const IContact *) const;
virtual bool getPropertyGlobal(uint i) const;
virtual bool setProperty(uint i,const QVariant &v,IContact *);
virtual bool getPropertyReadOnly(uint i) const;
enum MethodKeys { kwDeformability=1
, kwcohBond
, kwcohUnbond
};
virtual QString getMethods() const {
return "deformability"
",bond"
",unbond";
}
virtual QString getMethodArguments(uint i) const;
virtual bool setMethod(uint i,const QVector<QVariant> &vl,IContact *con=0); // Base 1 - returns true if timestep contributions need to be updated
virtual uint getMinorVersion() const;
virtual bool validate(ContactModelMechanicalState *state,const double ×tep);
//virtual bool endPropertyUpdated(const QString &name,const IContactMechanical *c);
virtual bool forceDisplacementLaw(ContactModelMechanicalState *state,const double ×tep);
virtual DVect2 getEffectiveTranslationalStiffness() const { DVect2 ret = effectiveTranslationalStiffness_; return ret;}
virtual DAVect getEffectiveRotationalStiffness() const {if (!cohProps_) return DAVect(0.0); return cohProps_->coh_AngStiff_;}
virtual ContactModelCohesive *clone() const { return NEWC(ContactModelCohesive()); }
virtual double getActivityDistance() const {return rgap_;}
virtual bool isOKToDelete() const { return !isBonded(); }
virtual void resetForcesAndMoments() { cohF(DVect(0.0)); cohM(DAVect(0.0));}
virtual bool checkActivity(const double &gap) { return (gap <= rgap_ || isBonded()); }
virtual bool isBonded() const { return cohProps_ ? (cohProps_->coh_state_==3) : false; }
bool hasPBond() const {return cohProps_ ? true:false;}
const double & rgap() const {return rgap_;}
void rgap(const double &d) {rgap_=d;}
int cohState() const {return hasPBond() ? cohProps_->coh_state_: 0;}
void cohState(int i) { if(!hasPBond()) return; cohProps_->coh_state_=i;}
double cohKn() const {return (hasPBond() ? (cohProps_->coh_kn_) : 0.0);}
void cohKn(const double &d) { if(!hasPBond()) return; cohProps_->coh_kn_=d;}
double cohKs() const {return (hasPBond() ? (cohProps_->coh_ks_) : 0.0);}
void cohKs(const double &d) { if(!hasPBond()) return; cohProps_->coh_ks_=d;}
double cohFric() const {return (hasPBond() ? (cohProps_->coh_fric_) : 0.0);}
void cohFric(const double &d) { if(!hasPBond()) return; cohProps_->coh_fric_=d;}
double cohTen() const {return (hasPBond() ? (cohProps_->coh_ten_) : 0.0);}
void cohTen(const double &d) { if(!hasPBond()) return; cohProps_->coh_ten_=d;}
double cohLamda() const {return (hasPBond() ? (cohProps_->coh_lamda_) : 0.0);}
void cohLamda(const double &d) { if(!hasPBond()) return; cohProps_->coh_lamda_=d;}
double cohAlpha() const {return (hasPBond() ? (cohProps_->coh_alpha_) : 0.0);}
void cohAlpha(const double &d) { if(!hasPBond()) return; cohProps_->coh_alpha_=d;}
double cohInelas() const {return (hasPBond() ? (cohProps_->coh_inelas_) : 0.0);}
void cohInelas(const double &d) { if(!hasPBond()) return; cohProps_->coh_inelas_=d;}
double cohDvar() const {return (hasPBond() ? (cohProps_->coh_dvar_) : 0.0);}
void cohDvar(const double &d) { if(!hasPBond()) return; cohProps_->coh_dvar_=d;}
double cohCoh() const {return (hasPBond() ? (cohProps_->coh_coh_) : 0.0);}
void cohCoh(const double &d) { if(!hasPBond()) return; cohProps_->coh_coh_=d;}
double cohPhiD() const {return (hasPBond() ? (cohProps_->coh_phid_) : 0.0);}
void cohPhiD(const double &d) { if(!hasPBond()) return; cohProps_->coh_phid_=d;}
double cohPhiF() const {return (hasPBond() ? (cohProps_->coh_phif_) : 0.0);}
void cohPhiF(const double &d) { if(!hasPBond()) return; cohProps_->coh_phif_=d;}
double cohwsig() const {return (hasPBond() ? (cohProps_->w_sig) : 0.0);}
void cohwsig(const double &d) { if(!hasPBond()) return; cohProps_->w_sig=d;}
double cohwcoh() const {return (hasPBond() ? (cohProps_->w_coh) : 0.0);}
void cohwcoh(const double &d) { if(!hasPBond()) return; cohProps_->w_coh=d;}
DVect cohF() const {return hasPBond() ? cohProps_->coh_F_: DVect(0.0);}
void cohF(const DVect &f) { if(!hasPBond()) return; cohProps_->coh_F_=f;}
DAVect cohM() const {return hasPBond() ? cohProps_->coh_M_: DAVect(0.0);}
void cohM(const DAVect &m) { if(!hasPBond()) return; cohProps_->coh_M_=m;}
DVect2 cohTransStiff() const {return hasPBond() ? cohProps_->coh_TransStiff_: DVect2(0.0);}
void cohTransStiff(const DVect2 &f) { if(!hasPBond()) return; cohProps_->coh_TransStiff_=f;}
DAVect cohAngStiff() const {return hasPBond() ? cohProps_->coh_AngStiff_: DAVect(0.0);}
void cohAngStiff(const DAVect &m) { if(!hasPBond()) return; cohProps_->coh_AngStiff_=m;}
const DVect2 & effectiveTranslationalStiffness() const {return effectiveTranslationalStiffness_;}
void effectiveTranslationalStiffness(const DVect2 &v ) {effectiveTranslationalStiffness_=v;}
private:
static int index_;
struct cohProps {
cohProps() : coh_kn_(0.0), coh_ks_(0.0), coh_fric_(0.0), coh_state_(0), coh_ten_(0.0), coh_coh_(0.0),
coh_alpha_(1.0), coh_lamda_(0.0), coh_phid_(0.0), coh_phif_(0.0), coh_dvar_(0.0), coh_inelas_(0.0),
coh_F_(DVect(0.0)), coh_M_(DAVect(0.0)), coh_TransStiff_(0.0), coh_AngStiff_(0.0) {}
// parallel bond
int coh_state_; // Contact mode - 0 (NBNF), 1 (NBFT), 2 (NBFS), 3 (B)
double coh_kn_; // normal stiffness
double coh_ks_; // shear stiffness
double kn0;
double ks0;
double coh_fric_; // Moment contribution factor
double coh_ten_; // normal strength
double coh_coh_; // friction angle
double ten0;
double coh0;
double coh_inelas_; // friction angle
double coh_alpha_; // soften normal stiffness
double coh_lamda_; // soften normal stiffness
double coh_phid_; // soften normal stiffness
double phid0;
double coh_phif_; // soften normal stiffness
double coh_dvar_; // soften normal stiffness
DVect coh_F_; // Force in parallel bond
DAVect coh_M_; // moment in parallel bond
double mn;
double ms;
double w_sig;
double w_coh;
DVect2 coh_TransStiff_; // (Normal,Shear) Translational stiffness of the parallel bond
DAVect coh_AngStiff_; // (Normal,Shear) Rotational stiffness of the parallel bond
};
void updateEffectiveStiffness(ContactModelMechanicalState *state);
DVect3 cohData(const IContactMechanical *con) const; // Bond area and inertia
DVect2 cohSMax(const IContactMechanical *con) const; // Maximum stress (tensile,shear) at bond periphery
double cohShearStrength(const double &cohArea) const; // Bond shear strength
double rgap_; // reference gap for the linear part
cohProps * cohProps_; // The parallel bond properties
DVect2 effectiveTranslationalStiffness_;
}; //ContactModelCohesive
} // cmodelsxd
最佳答案
具有抽象基类的原因是提供具体类必须实现的接口(interface)。您不应该创建抽象基类的实例。
使clone()
成为纯虚函数,不在基类中实现。仅在具体类中实现它。
virtual Contactmodel *clone() const = 0;
关于c++ - 错误 : object of abstract class type is not allowed when create an instance of a abstract class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32898797/
我正在 Angular js和sails.js(node.js框架)之间的cors问题上挣扎 我尝试修复错误:XMLHttpRequest无法加载http://localhost:1337/en/au
我在我的应用程序中动态创建一个 iframe,结果如下所示: 这样的沙箱配置是否安全(特别是允许将 iframe 内容视为来自同一来源)? 最佳答案 正如 Namey 评论的那样,allow-sam
突然,似乎没有更改我的网络应用程序中的任何内容,我在 Chrome 中打开它时开始收到 CORS 错误。我尝试添加 Access-Control-Allow-Origin: *标题。然后我得到这个错误
我正在使用 Ionic Framework 开发应用程序。 在后端,我为 api 编写了一个 Flask 应用程序,如下所示: @API.route("/saverez",methods=["POST
我正在尝试从 onesignal api 发送 POST 请求 代码 axios({ method: 'post', url: 'https://onesignal.com/api/v1/no
我一直在寻找一些类似的问题来寻找答案,但我找不到。我有一个带有 express 的 node.js 服务器: app.use(function(req, res, next) { res.head
我使用 Google Cloud Functions 创建了一个 API 端点,并试图从 JS 获取函数中调用它。 我遇到了我很确定与 CORS 或输出格式有关的错误,但我不确定发生了什么。其他一些
当我尝试从我的 Angular 6 应用程序访问 Webhdfs 时,我收到如下所示的错误。在我看来,我几乎尝试了所有方法,包括更改 core-site.xml 和 hdfs-site.xml 中的设
我刚刚学习 ajax 和 cors 一些东西,现在我想知道 chrome 插件“allow-control-allow-origin”是如何工作的。 当我尝试执行正常的 ajax 请求时,控制台显示错
我正在努力理解如何允许用户在列表中创建新记录,但只允许创建者更新他们自己的帖子。 例如。以下结构: post { post1: { author: "user1"
我们的网络上有 2 个内部(内联网)Windows 服务器,仅适用于本地网络。在 server1 上安装了 Spark,我们可以在其中查询 Jabber 信息,如下所示: http://server1
所以在 routing.yml 中我定义了以下路由,以便编辑和删除特定设置: 路由.yml: settings.editDefaults: path: settings/{id}/d
我哪里出错了 title $.get("http://api.angel.co/1/tags/1654/startups?callback=aaa", function(data
首先,对您可能犯的语法错误表示歉意。我的英语不是很好。 我是 Spring 新手,我正在尝试创建基本身份验证安全性。 我正在尝试配置一个端点具有公共(public)访问权限,而其他端点则具有用户访问权
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: NULL in MySQL (Performance & Storage) 如果出现以下情况,您是否强烈建议取消选中
我正在尝试将我的一个网站中的内容加载到另一个网站中: $('#include-from-outside').load('http://lujanventas.com/plugins/banne
这里出了什么问题? OPTIONS https://twitter.com/oauth/request_token 401 (Unauthorized) jsOAuth-1.3.4.js:483 XM
allow-control-allow-origin : * header 存在于 API 响应中,但浏览器仍显示错误。网络 403 错误。 这是来自 API 的示例响应 header : Acces
在 Go 中制作 slice 时的 capacity 参数对我来说意义不大。例如, aSlice := make([]int, 2, 2) //a new slice with length and
Gitlab 保护分支中“允许推送”和“允许 merge ”是什么意思 最佳答案 引用 Gitlab Documentation here Using the "Allowed to push" an
我是一名优秀的程序员,十分优秀!