所以我在getter中返回指针时遇到了一些问题
错误:
Return value type does not match the function type'
Run Code Online (Sandbox Code Playgroud)
我的班级标题:
class MyClass
{
private:
CustomModule clientModule;
bool initialized;
public:
MyClass();
CustomModule* getClientModule() const;
}
Run Code Online (Sandbox Code Playgroud)
Class cpp:
#include "MyClass.h"
MyClass::MyClass(){
initialized = true;
}
CustomModule* MyClass::getClientModule() const{
return &clientModule;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将文件上传到我的服务器但问题是if(isset($ _ FILES ['upl']))总是返回false
我的PHP:
if($_SERVER['REQUEST_METHOD'] == 'POST')
$allowed = array('png', 'jpg', 'gif', 'jpeg', 'bmp');
{
if(isset($_FILES['upl']) )
{
echo 'test';
$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
if(!in_array(strtolower($extension), $allowed)){
echo json_encode(array('success'=> false, 'message'=> 'No supported file type'));
exit;
}
$filename = "test".$extension;
if(move_uploaded_file($_FILES['upl']['tmp_name'], $url.'images/uploads/'.$filename)){
echo json_encode(array('success'=> true, 'url'=> $weburl .'images/uploads/'. $filename, 'filename' => $_FILES['upl']['name']));
exit;
}
}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<form action="" method="post">
<label for="file">Logo</label><input type="file" name="upl">
<input type="submit" disabled='disabled' value=''>
</form>
Run Code Online (Sandbox Code Playgroud)
如果在页面检查中我从不使用动作,使用一个不能解决问题
好的,所以我有一个结构,在一个单独的线程中不断更新.
现在我需要一些本地的变量,而不需要在它们之间进行更改.
我第一次这样做是为了让它们在本地获得,这显然不是最好的方法,但它有效.
float MyFloatArray[3];
MyFloatArray[0] = otherThread()->floatArray[0];
MyFloatArray[1] = otherThread()->floatArray[1];
MyFloatArray[2] = otherThread()->floatArray[2];
Run Code Online (Sandbox Code Playgroud)
现在我想知道是否有更好的方法来做到这一点.
我已经尝试过以下方法:
float MyFloatArray = otherThread()->floatArray;
float* MyFloatArray = otherThread()->floatArray; //Works but updates the otherThread array(Obviously) but that shouldn't happen
Run Code Online (Sandbox Code Playgroud)
由于我有一个相当大的项目,所以要将所有这些更新为很多工作 std::array<float,3>
还有其他选择吗?否则我将更新我的所有浮点数组,std::array<float,3>因为如果没有替代方案它会更清洁.