简单。强制编译器执行此操作: { ... addColumn(新CColumn(TIMESTAMP_COLUMN,this,CString( TIMESTAMP))); ... } 另一种解决方法是引入第三个构造函数 需要一个常量字符* - Karl Heinz Buchegger kb ****** @ gascad.at " Ron Natalie" ; < ro*@sensor.com>在消息中写道 news:40 ********************* @ news.newshosting.com。 .."Ron Natalie" <ro*@sensor.com> wrote in messagenews:40*********************@news.newshosting.com. .. 乔 < JR ***** @ purina.com>写在留言 news:ec ************************** @ posting.google.c om ... "Joe" <jr*****@purina.com> wrote in messagenews:ec**************************@posting.google.c om...当调用CDual()构造函数中的下一行时,带有CColumn :: CColumn签名的构造函数(CString columnType, CObject * aOwner ,bool batchUpdated)被调用,而不是我想要的那个。 When the line below in the CDual() constructor gets called, the constructor with the signature of CColumn::CColumn(CString columnType, CObject *aOwner, bool batchUpdated) gets invoked, rather than the one I want. 因为bool比chartring更适合char *。任何 Because the bool is a better match for char* than CString is. Any 指针都可以转换为bool,这是一个标准的转换序列。我假设CString有一个带有char *的转换构造函数。这是用户定义的转换序列。标准转换序列胜出。pointer can be converted to bool, and that is a standard conversion sequence. I assume CString has a converting constructor that takes a char*. This is a user-defined conversion sequence. The standard conversion sequence wins out. 这是语言的一部分,是标准的一部分,还是编译器 依赖,你推断'这是他的实施?Is this true for the language as part of the standard, or is it compilerdependent and you''re inferring that''s his implementation? 这篇关于错误的构造函数被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 22:14