我想在GitHub存储库中的Web中运行python文件.是否有可能做到这一点?
并通过在网络上运行,我的意思是把#!/usr/bin/python和print 'Content-type:text/html\n前两个行.
在C++中,如何区分一元和二元减运算符的运算符重载函数?
我试图用以下代码重载:
Vector Vector::operator-(){
return Vector(-x,-y,-z);
}
Vector Vector::operator-(const Vector& v){
return this* + (-v);
}
Run Code Online (Sandbox Code Playgroud)
但这会产生很多错误:
vector.cpp: In member function ‘Vector Vector::operator-(const Vector&)’:
vector.cpp:88:20: error: passing ‘const Vector’ as ‘this’ argument of ‘Vector Vector::operator-()’ discards qualifiers [-fpermissive]
return this* + (-v);
^
vector.cpp:88:16: error: no match for ‘operator+’ (operand type is ‘Vector’)
return this* + (-v);
^
vector.cpp:88:16: note: candidates are:
vector.cpp:70:8: note: Vector Vector::operator+(const Vector&)
Vector Vector::operator+(const Vector& v){
^
...
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?