我有一个使用多重继承和多态的C++应用程序.它在x86_64-linux上正常工作但在arm-linux上我遇到了分段错误.
我写了一个简单的测试来重新创建问题:
#include <list>
#include <iostream>
class SmartObject
{
public:
// removing this destructor makes it work in ANY way
virtual ~SmartObject(){
}
void method(void) {}
};
class IMyInterface
{
public:
// removing this destructor have no effect (fails)
virtual ~IMyInterface(){
}
virtual std::list<int> getList() = 0;
};
class MyObject : public SmartObject, public virtual IMyInterface
{
public:
MyObject()
{
list.push_back(4);
list.push_back(5);
}
virtual std::list<int> getList() {
return list;
}
std::list<int> list;
};
int main()
{
IMyInterface * ip = …Run Code Online (Sandbox Code Playgroud) 我的C程序采用随机int高值并将其转换为十六进制并将其写入文件.如果值为225919或更低,一切顺利.225875 00 03 72 53
但是如果该值高于225919,它开始ffffff为十六进制值示例885943中的最后一个字节写入额外的00 03 72 ffffff97,而正确的值将是00 03 72 97.
将值写入文件的代码如下:
char *temp = NULL;
int cze = 225943;
temp = (char *)(&cze);
for (ii = 3; ii >= 0; ii--) {
printf(" %02x ", temp[ii]); //just for printing the values
fprintf(in, "%02x", temp[ii]);
}
Run Code Online (Sandbox Code Playgroud)
输出是: 00 03 72 ffffff97
预期产量: 00 03 72 97
请帮忙,任何指针都表示赞赏.
团队,我正在尝试创建一个副本集,但出现错误:
验证数据时出错:
[ValidationError(ReplicaSet):io.k8s.api.apps.v1.ReplicaSet 中未知字段“replicas”,ValidationError(ReplicaSet):io.k8s.api.apps.v1.ReplicaSet 中未知字段“selector”,ValidationError(ReplicaSet) .spec): io.k8s.api.apps.v1.ReplicaSetSpec 中缺少必填字段“选择器”];如果您选择忽略这些错误,请使用 --validate=false 关闭验证
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: test-pod-10sec-via-rc1
labels:
app: pod-label
spec:
template:
metadata:
name: test-pod-10sec-via-rc1
labels:
app: feature-pod-label
namespace: test-space
spec:
containers:
- name: main
image: ubuntu:latest
command: ["bash"]
args: ["-xc", "sleep 10"]
volumeMounts:
- name: in-0
mountPath: /in/0
readOnly: true
volumes:
- name: in-0
persistentVolumeClaim:
claimName: 123-123-123
readOnly: true
nodeSelector:
kubernetes.io/hostname: node1
replicas: 1
selector:
matchLabels:
app: feature-pod-label
Run Code Online (Sandbox Code Playgroud) 我试图在' - '上拆分下面的字符串,但问题是,当它的两边都有字符时,拆分应该只发生' - '.
String s = "1 - 2 Foo - Bar 3 - 4 Wrong - Right"
Run Code Online (Sandbox Code Playgroud)
Ouptut
String[0] = 1 - 2 Foo
String[1] = Bar 3 - 4 Wrong
String[2] = Right
Run Code Online (Sandbox Code Playgroud)
有没有办法实现这一目标.