explicit

FOR XML EXPLICIT

安稳与你 提交于 2019-12-04 19:20:28
Say I have this setup: -- tables declare @main table (id int, name varchar(20)) declare @subA table (id int, mid int, name varchar(20)) declare @subA1 table (id int, subAid int, name varchar(20)) declare @subA2 table (id int, subAid int, name varchar(20)) declare @subB table (id int, mid int, name varchar(20)) -- sample data insert @main values (1, 'A') insert @main values (2, 'B') insert @SubA values (1, 1, 'A') insert @SubA values (2, 1, 'B') insert @SubA values (3, 2, 'C') insert @SubA1 values (1, 1, 'A') insert @SubA2 values (1, 2, 'A') insert @SubB values (1, 1, 'A') insert @SubB values

ASP.NET: explicit vs implicit localization?

坚强是说给别人听的谎言 提交于 2019-12-04 06:17:33
To my mind the advantage of implicit localization over explicit localization is that if you have more than one property to localize for a given control, it's a more economical syntax. In the case where you just need to localize some text I use the asp:Localize control which only has a single property (Text) that renders to the UI. Is there a reason to use one over the other? Any style preference? Are there any speed differences? Implicit <asp:Localize ID="Localize1" runat="server" meta:resourcekey="Something" /> vs Explicit <asp:Localize ID="Localize1" runat="server" Text="<%$ Resources

Foo f = Foo(); // no matching function for call to 'Foo::Foo(Foo)' … huh?

谁都会走 提交于 2019-12-04 00:54:20
class Foo { public: explicit Foo() {} explicit Foo(Foo&) {} }; Foo d = Foo(); error: no matching function for call to 'Foo::Foo(Foo)' I tried changing Foo(Foo&) to Foo(Foo) as the error suggests, which AFAIK is not a valid constructor, and sure enough I get: error: invalid constructor; you probably meant ‘Foo (const Foo&)’ What gives? How do I resolve this? (This is on GCC by the way) There are two questionable things that you have in your copy constructor. First, you've made the copy-constructor explicit (which is a questionable thing to do), so you would (in theory) need to do: Foo d( (Foo()

Why are function template specializations not allowed inside a class?

☆樱花仙子☆ 提交于 2019-12-03 06:58:52
After having found answers to many of my questions on stackoverflow, I have now come up against a question of which I can't find the answer and I hope that someone is willing to help me! My problem is that I want to do an explicit templatization of a function inside a class in C++. My compiler (g++) and a look in the C++ standard (§14.7.3) tells me that this specialization has to be done in the namespace in which the class is declared. I understand that this implies that I cannot put the specialization inside the class, but I don't see the point of this restriction! Does anyone know if there

Why is #include <string> preventing a stack overflow error here?

99封情书 提交于 2019-12-03 00:56:41
问题 This is my sample code: #include <iostream> #include <string> using namespace std; class MyClass { string figName; public: MyClass(const string& s) { figName = s; } const string& getName() const { return figName; } }; ostream& operator<<(ostream& ausgabe, const MyClass& f) { ausgabe << f.getName(); return ausgabe; } int main() { MyClass f1("Hello"); cout << f1; return 0; } If I comment out #include <string> I don't get any compiler error, I guess because it's kind of included through #include

Why is #include <string> preventing a stack overflow error here?

断了今生、忘了曾经 提交于 2019-12-02 14:20:06
This is my sample code: #include <iostream> #include <string> using namespace std; class MyClass { string figName; public: MyClass(const string& s) { figName = s; } const string& getName() const { return figName; } }; ostream& operator<<(ostream& ausgabe, const MyClass& f) { ausgabe << f.getName(); return ausgabe; } int main() { MyClass f1("Hello"); cout << f1; return 0; } If I comment out #include <string> I don't get any compiler error, I guess because it's kind of included through #include <iostream> . If I "right-click --> Go to Definition" in Microsoft VS they both point to the same line

Python, unable to convert input() to int()

末鹿安然 提交于 2019-12-02 05:40:42
问题 I am trying to convert input() data to int() with the following code: prompt_text = "Enter a number: " try: user_num = int(input(prompt_text)) except ValueError: print("Error") for i in range(1,10): print(i, " times ", user_num, " is ", i*user_num) even = ((user_num % 2) == 0) if even: print(user_num, " is even") else: print(user_num, " is odd") I get the following odd error when I enter asd2 for example: Enter a number: asd2 Error Traceback (most recent call last): File "chapter3_ex1.py",

Do you have to explicitly create instance of form in VB.NET? [duplicate]

你。 提交于 2019-12-01 19:51:56
问题 This question already has answers here : Why is there a default instance of every form in VB.Net but not in C#? (2 answers) Closed 3 years ago . If a project contains a Form class, can the form be shown by: Form1.Show or does an instance of the form need to be created first? Dim frm As New Form1 frm.Show 回答1: Yes it can, it is the default Form instance it was left in the Language for VB6 compatability. If it was me I would avoid it like the plague, it only muddies the waters. Create your own

Do you have to explicitly create instance of form in VB.NET? [duplicate]

元气小坏坏 提交于 2019-12-01 18:42:51
This question already has an answer here: Why is there a default instance of every form in VB.Net but not in C#? 2 answers If a project contains a Form class, can the form be shown by: Form1.Show or does an instance of the form need to be created first? Dim frm As New Form1 frm.Show Yes it can, it is the default Form instance it was left in the Language for VB6 compatability. If it was me I would avoid it like the plague, it only muddies the waters. Create your own instances instead. As has been suggested, using the form name uses the default instance while you second snippet explicitly

Strings and ints, implicit and explicit

微笑、不失礼 提交于 2019-12-01 16:02:30
Had a coworker ask me this, and in my brain befuddled state I didn't have an answer: Why is it that you can do: string ham = "ham " + 4; But not: string ham = 4; If there's an implicit cast/operation for string conversion when you are concatenating , why not the same when assigning it as a string? (Without doing some operator overloading, of course) When concatenating the compiler turns the statement "ham" + 4 into a call to String.Concat , which takes two object parameters, so the value 4 is boxed and then ToString is called on that. For the assignment there is no implicit conversion from int