构造函数问题 - 急需解决此问题的帮助 [英] Constructor problem - help needed urgently to resolve this

查看:76
本文介绍了构造函数问题 - 急需解决此问题的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一些示例代码,我想改装到我的

项目中。示例中的代码包含以下行:


SharedAppenderPtr myAppender(new RollingFileAppender(" MyAppender"))

我想移动这行代码到包装类中的构造函数,所以

我可以在对象'

构造期间确定合适的Appender名称。


我已经完成了ff:


在我的包装类中声明了一个私有变量为ff:

SharedAppenderPtr m_Appender;


在我的(包装类)构造函数中,我有以下代码:


.....

m_Appender = new RollingFileAppender(log_file_name )

.....

但是,我收到链接错误(未解析的外部符号)。我认为我可以用这种

方式使用复制作业,这显然是错误的。这是我得到的实际liker错误(虽然我在这个例子中使用MS

工具,但我不相信它是MS特定的问题)。

审计错误LNK2019:未解析的外部符号" __ declspec(dllimport)

public:class log4cplus :: helpers :: SharedObjectPtr< class

log4cplus :: Appender> ; &安培; __thiscall

log4cplus :: helpers :: SharedObjectPtr< class

log4cplus :: Appender> :: operator =(class log4cplus :: Appender *)"

(__imp _ ?? 4?$ SharedObjectPtr @ VAppender @ log4cplus @@@ helpers @ log4cplus @@ QAEAAV012 @ PAVAppender @ 2 @@ Z)

在函数public:__thiscall Auditor中引用: :Auditor(int,int)"

(?? 0Auditor @@ QAE @HH @ Z)


任何有用的建议(或更好的是,将非常感谢

问题的实际解决方案。


MTIA

Hi,

I have some code from an example, that I want to retrofit into my
project. The code from the example has the following line:

SharedAppenderPtr myAppender( new RollingFileAppender("MyAppender"))
I want to move this line of code to a constructor in a wrapper class, so
that I can determine the appropriate Appender name during the object''s
construction.

I have done the ff:

declared a privariate variable in my wrapper class as ff:
SharedAppenderPtr m_Appender ;

In my (wrapper class) constructor, I have the following code:

.....
m_Appender = new RollingFileAppender(log_file_name)
.....
However, I am getting linking errors (unresolved external symbol). I was
obviously wrong in thinking that I could use copy assignment in this
way. This is the actual liker error I''m getting (Although I am using MS
tools in this instance, I don''t believe its a MS specific problem).

Auditor error LNK2019: unresolved external symbol "__declspec(dllimport)
public: class log4cplus::helpers::SharedObjectPtr<class
log4cplus::Appender> & __thiscall
log4cplus::helpers::SharedObjectPtr<class
log4cplus::Appender>::operator=(class log4cplus::Appender *)"
(__imp_??4?$SharedObjectPtr@VAppender@log4cplus@@@ helpers@log4cplus@@QAEAAV012@PAVAppender@2@@Z)
referenced in function "public: __thiscall Auditor::Auditor(int,int)"
(??0Auditor@@QAE@HH@Z)

Any helpful suggestions (or better still, an actual solution to the
problem) will be greatly appreciated.

MTIA

推荐答案

SharedObjectPtr @ VAppender @ log4cplus @@@ helpers @ log4cplus @@ QAEAAV012 @ PAVAppender @ 2 @@ Z)

在函数中引用public:__thiscall Auditor :: Auditor( int,int)"

(?? 0Auditor @@ QAE @HH @ Z)


任何有用的建议(或更好的是,实际的解决方案

问题)将不胜感激。


MTIA

SharedObjectPtr@VAppender@log4cplus@@@ helpers@log4cplus@@QAEAAV012@PAVAppender@2@@Z)
referenced in function "public: __thiscall Auditor::Auditor(int,int)"
(??0Auditor@@QAE@HH@Z)

Any helpful suggestions (or better still, an actual solution to the
problem) will be greatly appreciated.

MTIA


* Alfonso Morra:
* Alfonso Morra:

在我的(包装类)构造函数中,我有以下代码:

....
m_Appender = new RollingFileAppender(log_file_name)
....

In my (wrapper class) constructor, I have the following code:

....
m_Appender = new RollingFileAppender(log_file_name)
....




不要。使用构造函数初始化列表。初始化不是

赋值。


-

答:因为它弄乱了人们通常阅读文本的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet上最烦人的事情是什么并在电子邮件中?



Don''t. Use a constructor initializer list. Initialization is not
assignment.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?





Alf P. Steinbach写道:


Alf P. Steinbach wrote:
* Alfonso Morra:
* Alfonso Morra:
在我的(包装类)构造函数中,我有以下代码:

....
m_Appender = new RollingFileAppender(log_file_name)
....
In my (wrapper class) constructor, I have the following code:

....
m_Appender = new RollingFileAppender(log_file_name)
....



不要。使用构造函数初始化列表。初始化不是分配。


Don''t. Use a constructor initializer list. Initialization is not
assignment.




我认为你错过了我正在制作的观点。值得注意的是:

私有变量在其他地方声明(意味着默认构造

被调用)。那么我必须使用构造函数中传递的参数

创建一个实例。一种方法可能是声明ptrs

返回指向对象的指针而不是对象本身 - 只是

a猜测,我想听听更有经验的C ++人员但是,

如果这是解决这个问题的好方法。



I thoink you''re missing the point I''m making. TThe point being this: The
private variable is declared somewhere else (meaning default construct
is invoked). THEN I have to create an instance using the parameters
passed in the constructor. One way round this may be to declare ptrs
return pointers to the objects instead of the objects themselves - just
a guess, I would like to hear from a more experienced C++ person though,
if this is a good way to overcome this issue.


这篇关于构造函数问题 - 急需解决此问题的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆