我正在研究C++,我无法理解下面粗体句子的含义:
来自IBM手册:
以下限制适用于构造函数和析构函数:
- 构造函数和析构函数没有返回类型,也不能返回值.
- 引用和指针不能用于构造函数和析构函数,因为它们的地址不能被使用.
- 无法使用关键字virtual声明构造函数.
- 构造函数和析构函数不能声明为static,const或volatile.
- 联合不能包含具有构造函数或析构函数的类对象.
你能给我举个例子吗?谢谢!
我用我的Gmail帐户配置了msmtp.我显然想避免在配置文件中以纯文本格式编写密码.幸运的是,msmtp提供了passwordeval可用于从可执行文件的输出中获取密码的选项.
问题是:我应该如何使用它?
我在这里找到了以下建议:
passwordeval gpg -d /some/path/to/.msmtp.password.gpg
这对我来说没有多大意义:如果有人能够访问我的配置文件,他肯定会设法运行这样的命令并从gpg获取密码.
所以我相信我留下了在二进制可执行文件中混淆密码的唯一选择,即使我几乎到处都读到这很糟糕!
我不可能实现的是:如果sendmail进程正在运行输出正确的传递,否则给出一个假传递.
你的建议?其他(更安全)技巧不同于将传递存储在二进制文件中?
我正在尝试创建一个类似于yapsy的插件框架(不幸的是yapsy不兼容python3).
我的代码看起来像这样:
root
main.py
plugins/
__init__.py
PluginManager.py
UI/
__init__.py
textui.py
Run Code Online (Sandbox Code Playgroud)
在PluginManager.py中我定义了以下类:
class PluginMetaclass(type):
def __init__(cls, name, base, attrs):
if not hasattr(cls, 'registered'):
cls.registered = []
else:
cls.registered.append((name,cls))
class UI_Plugins(object):
__metaclass__ = PluginMetaclass
#...some code here....
def load():
#...some code here too...
if "__init__" in os.path.basename(candidate_filepath):
sys.path.append(plugin_info['path'])
try:
candidateMainFile = open(candidate_filepath+".py","r")
exec(candidateMainFile,candidate_globals)
except Exception as e:
logging.error("Unable to execute the code in plugin: %s" % candidate_filepath)
logging.error("\t The following problem occured: %s %s " % (os.linesep, e))
if "__init__" in os.path.basename(candidate_filepath): …Run Code Online (Sandbox Code Playgroud) 以下代码填满了我的所有记忆:
from sys import getsizeof
import numpy
# from http://stackoverflow.com/a/2117379/272471
def getSize(array):
return getsizeof(array) + len(array) * getsizeof(array[0])
class test():
def __init__(self):
pass
def t(self):
temp = numpy.zeros([200,100,100])
A = numpy.zeros([200], dtype = numpy.float64)
for i in range(200):
A[i] = numpy.sum( temp[i].diagonal() )
return A
a = test()
memory_usage("before")
c = [a.t() for i in range(100)]
del a
memory_usage("After")
print("Size of c:", float(getSize(c))/1000.0)
Run Code Online (Sandbox Code Playgroud)
输出是:
('>', 'before', 'memory:', 20588, 'KiB ')
('>', 'After', 'memory:', 1583456, 'KiB ')
('Size of c:', 8.92) …Run Code Online (Sandbox Code Playgroud)