using

Is Close() same as Using statement

喜夏-厌秋 提交于 2020-04-21 02:30:22
问题 Is Close() same as Dispose() or using statement. Is it necessary to call using statement even if Close is called?. I know before disposing of an object, close should be called, so we close the resource and may it available to Dispose . https://msdn.microsoft.com/en-us/library/aa355056(v=vs.110).aspx says Close is same as Dispose . 回答1: Close() has no relation to IDisposable interface, see: https://msdn.microsoft.com/en-us/library/system.idisposable(v=vs.110).aspx using only applies to

Rust “use” vs. C++ “using namespace”

不打扰是莪最后的温柔 提交于 2020-01-22 18:33:14
问题 Is it considered bad style to declare multiple "use" statements in Rust? I am a C++ programmer that recently began trying out Rust. One thing I've noticed as I review Rust code is that in many Rust programs there will be a bunch of use statements at the top of the program. Coming from C++, it was discouraged to use using namespace std especially when making header files, but that doesn't seem to be the case in most of the Rust programs I've seen. So which of the following trivial examples is

Using declaration for type alias template in derived class with tempate base

谁都会走 提交于 2020-01-14 07:46:09
问题 If the base class depends on the template parameter, its scope is not examined in the unqualified name lookup. I can use the using declaration to introduce names from the base class. Suppose now I have a type alias template in the base class. Can the using declaration be used to introduce it into the derived class? template<class T> struct Base { using Type1 = int; template<typename S> using Type2 = S; }; template<class T> struct Derived : Base<T> { using typename Base<T>::Type1; // Fine /

Use of 'using' keyword to make inherited constructor public [duplicate]

夙愿已清 提交于 2020-01-13 08:17:20
问题 This question already has an answer here : C++11 inheriting constructors and access modifiers (1 answer) Closed 5 years ago . I am trying to test protected methods and constructors of my class. For this purpose, I tried to subclass it, and re-export its members as public with C++11 using keyword: class Foo { protected: Foo(int i) {} void run() {} }; class TestableFoo : public Foo { public: using Foo::Foo; using Foo::run; }; int main() { TestableFoo foo(7); foo.run(); } However, both g++ and

Use of 'using' keyword to make inherited constructor public [duplicate]

匆匆过客 提交于 2020-01-13 08:14:09
问题 This question already has an answer here : C++11 inheriting constructors and access modifiers (1 answer) Closed 5 years ago . I am trying to test protected methods and constructors of my class. For this purpose, I tried to subclass it, and re-export its members as public with C++11 using keyword: class Foo { protected: Foo(int i) {} void run() {} }; class TestableFoo : public Foo { public: using Foo::Foo; using Foo::run; }; int main() { TestableFoo foo(7); foo.run(); } However, both g++ and

C++ Name Resolution

寵の児 提交于 2020-01-12 07:53:06
问题 I'm wondering a bit about the namespace and using in C++ basically I would like to know the differences and figure out how to use it in the best way. As I see it there are (at least) three ways to resolve a class name and I am not sure how to choose among them: using namespace <namespace> using <namespace>::<what_to_use> <namespace>::<what_to_use> <use_it> I would like to know the advantages especially if there are performance involved in one or the other way, if it's just syntactical and a

Why does this Using() give me an error?

与世无争的帅哥 提交于 2020-01-10 03:50:06
问题 I am trying to open an (hundreds actually) excel file(s). I open the application but want to use the Using() functionality around each of the workbooks I open. Why is this resulting in an error? using (Excel.Workbook wbXL = appXL.Workbooks.Open(_sourceFullPath, Type.Missing, Excel.XlFileAccess.xlReadOnly)) { //stuff with wbXL } using gets the red underline and says "'Microsoft.Office.Interop.excel.Workbook':Type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Why shouldn't I put “using namespace std” in a header?

烈酒焚心 提交于 2020-01-09 11:56:09
问题 Someone once hinted that doing this in a header file is not advised: using namespace std; Why is it not advised? Could it cause linker errors like this: (linewrapped for convenience) error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >:: ~basic_string<char,struct std::char_traits<char>,class std::allocator<char> > (void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in tools.lib

How is performance affected by an unused using directive?

百般思念 提交于 2020-01-08 16:07:54
问题 Visual Studio will automatically create using statements for you whenever you create a new page or project. Some of these you will never use. Visual Studio has the useful feature to "remove unused usings". I wonder if there is any negative effect on program performance if the using statements which are never accessed, remain mentioned at the top of the file. 回答1: An unused using has no impact to the runtime performance of your application. It can affect the performance of the IDE and the

How is performance affected by an unused using directive?

别说谁变了你拦得住时间么 提交于 2020-01-08 16:07:38
问题 Visual Studio will automatically create using statements for you whenever you create a new page or project. Some of these you will never use. Visual Studio has the useful feature to "remove unused usings". I wonder if there is any negative effect on program performance if the using statements which are never accessed, remain mentioned at the top of the file. 回答1: An unused using has no impact to the runtime performance of your application. It can affect the performance of the IDE and the