首页 \ 问答 \ 工厂方法模式(Factory method pattern)

工厂方法模式(Factory method pattern)

工厂方法究竟是什么? 如何用dll实现?


What exactly is the factory method? How can it be implemented with dll?


原文:https://stackoverflow.com/questions/4954148
更新时间:2022-02-26 15:02

最满意答案

步骤1(“添加引用”)用于链接器,步骤2(“其他包含目录”)用于编译器。

确实,IDE可以足够智能,可以自动运行第2步。 但是,您可能无法添加整个B的代码文件夹以供C查看。 很可能你的意思是只指向一个列出B接口(公共头文件)的文件夹, C不应该看到B私有/内部头文件,也不应该看到B源代码:IDE确实难以找出它的确切位置,这就是为什么用户应该手动完成。

对于你的上一个问题:“专家”所做的是他们通常不会手动编辑/维护IDE文件,他们可以通过像CMake这样的工具生成它们。 然后,当结构发生变化时,它们只是重新生成项目(sln / vcproj)文件(再次运行CMake)。


Step 1 ("Add references") is for the linker, Step 2 ("Additional Include Directories") is for the compiler.

It's true that the IDE could be smart enough to operate step 2 automatically. However, you may not add the whole B's code folder to be seen by C. Most likely you meant to only point to a folder listing B interfaces (public header files), C should not see B private/internal headers nor B source code: it's surely too difficult for the IDE to figure out where it is exactly, that's why the user should do it manually.

For your last questions: what "experts" do is that they commonly don't edit/maintain IDE files by hand, they have them be generated by a tool, like CMake. Then, when structure changes, they just re-generate the project (sln/vcproj) files (run CMake again).

相关问答

更多
  • 此错误是编译错误。 您需要在Properties-> C \ C ++ - > General-> Aditional include directories中包含.h文件。 编译完成后会有一个链接错误。 为此,您将转到选项属性 - >链接器 - >其他库目录,您将指定一个包含库的文件夹。 然后转到属性 - >链接器 - >输入 - >附加依赖项,并从该文件夹中指定所需的.lib文件。 在那里你也可以添加abosulte路径而不添加我认为的其他选项。 不知道为什么他们有两个地方...... This err ...
  • Eclipse具有内置的Ant支持。 您可以利用它自动创建当前项目的JAR并将其放入另一个项目的文件夹中。 假设EventKitchenAndroid和EventKitchenCore项目都在同一个工作区中,请在EventKitchenCore项目中创建一个build.xml文件,其中包含以下内容:
  • 我不确定这是“正确的”还是最好的方式,但它对我有用。 我不使用SVN,所以我不知道这会如何影响这种方法。 在指定源集的位置,可以指定其他目录。 假设我的库项目的根目录与我当前的工作项目在同一目录中。 我会更改此行,如sourcesets部分所示: java.srcDirs = ['src', '../myLibraryProject/src'] 你也可以为res.srcDirs做同样的res.srcDirs 。 这会产生一个看起来很滑稽的目录树,它会显示另外的源目录作为项目根目录的兄弟,并且项目自己的sr ...
  • 我终于解决了我的问题。 似乎我唯一遗漏的是链接build.gradle文件中的共享库。 喜欢这个: ldFlags += "-L${file(path/to/libssl.so)}".toString() ldLibs += ["ssl"] I finally solved my problem. It seems that the only thing I missed is link against the shared libraries in the build.gradle file. Lik ...
  • 未构建引用的项目时,引用的路径将指向obj目录中的DLL。 构建之后,路径将自动指向bin目录中的(现在存在的DLL)。 When the referenced project isn't built, the reference's path will point to a DLL in the obj directory. After it has been built, the path will automatically point to a (now existing DLL) in the b ...
  • 如果你看看boost,你会注意到他们使用类似的方案: #include 它的优点是可以防止与另一个依赖项中另一个类似命名的文件发生冲突。 然而,在提升的情况下,他们更进一步。 如果包含 ,那么您可能正在处理名为::x::y::z的实体(无论是函数还是类)。 也就是说,项目中的目录布局模仿命名空间组织。 定位自己真的很整洁。 通常,大多数项目都隐藏在子目录(和子名称空间)中,但为了方便起见,最常用的项目被拉入boost命名空间,因此它们的头 ...
  • 正如你现在所发现的那样,属性表通常是让这样的事情部分自动化的简单方法(另一种方式是像VcPkg这样的包管理,但据我所知,还没有(尚未)正确建立,并不像创建单个文件并通过几次单击将其添加到项目中。 在这种情况下:创建一个属性表,将附加的D:\ external添加到AdditionalIncludeDirectories并在需要它的所有项目中导入工作表。 此外,如果您不使用pragma进行自动链接和/或库不在所有项目已知的公共位置,您可以将库搜索路径和库本身添加到属性表中的链接器输入以获取编译器和链接器快乐。 ...
  • 步骤1(“添加引用”)用于链接器,步骤2(“其他包含目录”)用于编译器。 确实,IDE可以足够智能,可以自动运行第2步。 但是,您可能无法添加整个B的代码文件夹以供C查看。 很可能你的意思是只指向一个列出B接口(公共头文件)的文件夹, C不应该看到B私有/内部头文件,也不应该看到B源代码:IDE确实难以找出它的确切位置,这就是为什么用户应该手动完成。 对于你的上一个问题:“专家”所做的是他们通常不会手动编辑/维护IDE文件,他们可以通过像CMake这样的工具生成它们。 然后,当结构发生变化时,它们只是重新生 ...
  • 看看PinpointTownes如何在他的OpenIddict项目中实现这一点。 您可以将UseStaticFiles调用与EmbeddedFileProvider一起使用。 它是rc1-final软件包的一部分,你可以在这里看到。 相关代码可在GitHub上找到 。 仅供未来读者使用: app.UseStaticFiles(new StaticFileOptions { FileProvider = new EmbeddedFileProvider( assembl ...
  • 如果您没有将BaseLibrary添加到MyProject ,它可以正常工作。 那你就不必问自己这个问题了。 然而,如果它不起作用,那么无论如何你必须添加它。 If you do not add BaseLibrary to MyProject and it works fine. Then you don't have to ask yourself the question. Whereas if it doesn't work without, so you must add it anyway.

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。