我想向工作类添加记录器函数,如何将成员函数作为函数指针传递?使用 mem_fun 吗?
这是代码示例:
class Work{
public:
void (*logger) (const string &s);
void do_sth(){if (logger) logger("on log")};
};
classs P{
public:
void log(const string &s)(cout << s);
};
int main(){
Work w;
P p;
w.logger = &p.log;
w.do_sth();
}
Run Code Online (Sandbox Code Playgroud)
编辑:
我不想使用 void (P::*xxx)() 因为它坚持类 P ...
我知道C++隐藏……,真正的日志函数是:void log(P &p, const string &s),
真正的项目是这样的:
我创建了一个 CDialog,并且有一个日志功能,它将日志字符串复制到 CEdit。
所以我需要把这个日志函数传递给一个 Worker 类,这个类做一些串口工作,
我需要记录并显示发送和接收的数据...
我即将完成一本书"Flex on Java",它要求我安装maven 2+我从apache网站下载maven.添加 :
M2_HOME = C:\apache-maven-2.2.1
Run Code Online (Sandbox Code Playgroud)
和
M2 = %M2_HOME%\bin
Run Code Online (Sandbox Code Playgroud)
根据http://maven.apache.org/download.html上的说明进入环境变量,
然后它到达数字6,表示"在同一个对话框中,更新/创建用户变量中的Path环境变量并预先添加%M2%在命令行中添加Maven的值."
我应该编辑和添加哪个环境变量%M2%?
谷歌搜索后,我找到了一个帖子,上面写着"附加",而不是在JAVA_HOME
我尝试预先添加并将其附加到java home var 的值之前,但当我尝试从命令行执行mvn命令时,它说它无法识别.
从来没有使用过maven,所以这是我的第一次设置.任何人都可以看到我做得不对或我需要做什么才能使用mvn命令,拜托并谢谢你.
在Emacs Lisp(elisp)中,如果我想从用户那里获得几个值,有没有比在迷你缓冲区中依次询问每个值更好的方法?
理想情况下,会有一个库让我可以定义一个包含多个字段的输入表单,将该表单呈现给用户(在文本模式下作为基于文本的对话框,在GUI模式下作为基于GUI的对话框),并让我查询结果.纯文本库也可以.
有没有这样的图书馆?
谢谢!
伊利亚
我正在尝试使用Blobstore API在GAE中上传文件.我在本地运行GAE服务器时遇到以下异常(开发模式):
WARNING: /_ah/upload/ag10cmlwc2NoZWR1bGVychsLEhVfX0Jsb2JVcGxvYWRTZXNzaW9uX18YFQw
java.lang.IllegalStateException: Must call one of set*BlobStorage() first.
at com.google.appengine.api.blobstore.dev.BlobStorageFactory.getBlobStorage(BlobStorageFactory.java:24)
at com.google.appengine.api.blobstore.dev.UploadBlobServlet.init(UploadBlobServlet.java:88)
at javax.servlet.GenericServlet.init(GenericServlet.java:215)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
Run Code Online (Sandbox Code Playgroud)
我正在运行GAE 1.3.5,但是自GAE 1.3.0(Blobstore的第一个版本)以来已经尝试过所有版本.我正在使用GAE maven插件:http://code.google.com/p/maven-gae-plugin/
我的表单是用GWT 2.0.4编写的.目前,表单只是一个带有提交的文件输入字段.
我在提交表格后收到上述例外情况.我能够从Blobstore服务成功检索上传URL.
在GAE上一切正常.我已经验证在本地开发环境中没有输入任何内容(通过开发管理控制台).我正在上传一张~1Kb的CSV,但尝试了其他文件类型/大小也没有成功(相同的文件适用于GAE prod).
gwt google-app-engine blobstore maven-gae-plugin google-cloud-datastore
如果我要从不受信任的来源获取数据库(在本例中为postgresql),是否存在激活它并查询它的风险?
我是Objective-C(和stackoverflow)的新手,我有点关于属性的最佳实践.
我的理解是,当你完全使用属性时,可以通过释放它们来避免错误,然后立即设置为nil,以便后续消息也返回nil而不是异常.
[myProperty release],myProperty = nil;
但是,当涉及到"复制"和"保留"属性的dealloc时,是否需要同时执行这两个操作?或做一个简单的
[myProperty发布]剪了吗?另外,我是否正确,我不需要在dealloc中释放'assign'属性?
谢谢!
所以我正在测试UIView动画,我注意到CALayer渲染的阴影(使用[view.layer setShadowStuffHere])在动画开始时消失,并在动画结束时重新出现.有什么方法可以保持这些阴影,并让阴影与UIView一起动画?我尝试使用没有边框路径的阴影,但这是一个糟糕的主意,因为在动画期间帧速率像摇滚一样下降,而且我没有得到阴影.
我现在使用的代码如下.最初你看到一个红色的视图,当点击时,它会翻转成一个更大的蓝色视图.最终结果应该类似于iPad音乐应用程序; 当选择一张专辑时,它会翻转以显示背面的视图.
- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer * tapRec;
// Drop shadow Path creation
CGFloat x1 = 0;
CGFloat y1 = 0;
CGFloat x2 = 100;
CGFloat y2 = 100;
frontBorderPath = CGPathCreateMutable();
CGPathMoveToPoint(frontBorderPath, NULL, x1, y1);
CGPathAddLineToPoint(frontBorderPath, NULL, x2, y1);
CGPathAddLineToPoint(frontBorderPath, NULL, x2, y2);
CGPathAddLineToPoint(frontBorderPath, NULL, x1, y2);
CGPathAddLineToPoint(frontBorderPath, NULL, x1, y1);
x2 = 400;
y2 = 400;
backBorderPath = CGPathCreateMutable();
CGPathMoveToPoint(backBorderPath, NULL, x1, y1);
CGPathAddLineToPoint(backBorderPath, NULL, x2, y1);
CGPathAddLineToPoint(backBorderPath, NULL, x2, y2);
CGPathAddLineToPoint(backBorderPath, …Run Code Online (Sandbox Code Playgroud) 关于C++中const和非const方法之间的区别,我有几个问题.
例:
MyObject* MyClass::objectReference()
const MyObject* MyClass::objectReference() const
Run Code Online (Sandbox Code Playgroud)
我的问题是:
如何用mingw gcc链接msvcr90.dll?我试过-lmsvcr90,这是最小的例子:
#include <stdio.h>
int main(int argc, const char *argv[]) {
printf("%s\n", "hello");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的操作系统是win7,mingw gcc 4.5.0
$ gcc -v
...
gcc version 4.5.0 (GCC)
$ gcc hello.c -lmsvcr90
$ a
Run Code Online (Sandbox Code Playgroud)
然后我收到了这个错误:
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
我错过了哪一部分?
EDIT1:
@ user440813似乎我的mingw与你的明显不同.
$ gcc h.c -nostdlib -lmsvcr70 -lgcc -o h.exe
d:/mingw/bin/../lib/gcc/mingw32/4.5.0/libgcc.a(__main.o):(.text+0x5a): undefined reference to `atexit'
d:/mingw/bin/../lib/gcc/mingw32/4.5.0/libgcc.a(__main.o):(.text+0xc2): undefined reference to `atexit'
collect2: …Run Code Online (Sandbox Code Playgroud) 所以即时通讯试图为我的ListView设置一个setOnClickListener,但由于某种原因导致我的程序崩溃,当我尝试..我很新的编程所以当涉及到故障排除我不能真的做任何可悲的事情:(我的代码是在下面所以任何关于可能出错的想法都会非常有帮助
public class HomePageActivity extends Activity {
//ListView that holds the items
ListView lstTest;
//Array Adapter that holds the ArrayList and displays the items on the ListView
AlertsAdapter arrayAdapter;
//List that hosts the items
ArrayList<Alerts> alrts = null;
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.homepage);
//Initialize the ListView
lstTest = (ListView)findViewById(R.id.lstText);
//Initialize the ArrayList
alrts = new ArrayList<Alerts>();
//Initialize the array adapter
arrayAdapter = new AlertsAdapter(HomePageActivity.this, R.layout.listitems,alrts);
//Set the above …Run Code Online (Sandbox Code Playgroud) c++ ×2
android ×1
blobstore ×1
calayer ×1
cocoa-touch ×1
database ×1
doxygen ×1
elisp ×1
emacs ×1
gcc ×1
gwt ×1
ipad ×1
iphone ×1
listview ×1
maven-2 ×1
mingw ×1
msvcr90.dll ×1
objective-c ×1
postgresql ×1
uikit ×1