declaration

Variables scope which are defined within a while block in stored procedures - SQl Server

我只是一个虾纸丫 提交于 2019-11-28 22:23:20
问题 I've come across a interesting scenario (at least for me) in a stored procedure. Would like to have experts opinion and thoughts on it. DECLARE @loopcounter INT SET @loopcounter=10 WHILE @loopcounter > 0 BEGIN DECLARE @insidevalue int IF (@loopcounter%2 = 0) SET @insidevalue = @loopcounter PRINT 'Value_' + CAST(@insidevalue AS NVARCHAR) + '_' SET @loopcounter = @loopcounter - 1 END I was expecting this block will give the output as below Value_10_ Value_ _ Value_8_ Value_ _ Value_6_ Value_ _

Redundancy in OCaml type declaration (ml/mli)

放肆的年华 提交于 2019-11-28 22:13:01
问题 I'm trying to understand a specific thing about ocaml modules and their compilation: am I forced to redeclare types already declared in a .mli inside the specific .ml implementations? Just to give an example: (* foo.mli *) type foobar = Bool of bool | Float of float | Int of int (* foo.ml *) type baz = foobar option This, according to my normal way of thinking about interfaces/implementations, should be ok but it says Error: Unbound type constructor foobar while trying to compile with ocamlc

extern declaration, T* v/s T[]

眉间皱痕 提交于 2019-11-28 21:56:11
I saw following piece of code in a legacy project. /* token.c */ struct token id_tokens[MAX_TOKENS]; /* analyse.c (v1) */ extern struct token *id_tokens; /* Raised my eyebrow, id_token declares a pointer */ I insisted on changing analyse.c to contain the declaration as below: /* analyse.c (v2) */ extern struct token id_tokens[]; /* I am happy with this. id_tokens declares array of unspecified size. */ I want v2 because pointer to T is not same as array of T . My friend's counter argumented that behaviour of both are same, so it doesn't matter whether I use v1 and v2. Question 1: Does array of

How to read so many stars and parentheses in a templated function-pointer declaration? [duplicate]

左心房为你撑大大i 提交于 2019-11-28 21:37:46
This question already has an answer here: Complex C declaration 7 answers From Introduction to the C++11 feature: trailing return types The article claims template <class T> class tmp { public: int i; }; auto foo()->auto(*)()->tmp<int>(*)(){ return 0; } is equivalent to template <class T> class tmp{ public: int i; }; tmp<int> (*(*foo())())() { return 0; } I don't understand the complex function in the second code example. Where should I look at in the beginning? I guess is foo . But the stat right next to foo is going to define foo as a pointer... Based on the first code example, I will

When to use UIKIT_EXTERN vs just extern

半世苍凉 提交于 2019-11-28 21:29:41
I'm guessing I would only use UIKIT_EXTERN if there is a chance of C++ code in my project that may use the variable. If this is the case wouldn't it just be safe to declare all your externally available constants with UIKIT_EXTERN? How come I don't see this more? I'm guessing I would only use UIKIT_EXTERN if there is a chance of C++ code in my project that may use the variable. Right. This is the primary reason. This happens because C and C++ symbols use different naming conventions. There is a less common reason: UIKIT_EXTERN also specifies default visibility. Note: More generally, "symbol" -

Where in a declaration may a storage class specifier be placed?

末鹿安然 提交于 2019-11-28 20:30:18
For example, let's consider the static storage class specifier. Here are a few examples of both valid and ill-formed uses of this storage class specifier: static int a; // valid int static b; // valid static int* c; // valid int static* d; // valid int* static e; // ill-formed static int const* f; // valid int static const* g; // valid int const static* h; // valid int const* static i; // ill-formed typedef int* pointer; static pointer j; // valid pointer static k; // valid (The declarations marked "valid" were accepted by Visual C++ 2012, g++ 4.7.2, and Clang++ 3.1. The declarations marked

Eclipse Open declaration in Java project

左心房为你撑大大i 提交于 2019-11-28 20:03:29
In an Eclipse SVN project I have a problem; when I tried to open a declaration of one class, I got this error: Problems opening an editor Reason : projectname does not exist. Also refactoring does not work. I have searched the web and tried all found solutions but nothing helped. I have downloaded different Eclipse and Java versions and switched to a clean workspace but I still have the problem. How can I solve my problem or which solution can I try? Right Click on the project -> Properties -> Project Facets -> Click on the Configuration Link -> Click on Apply Button -> Click on OK button. The

How to add constructors/destructors to an unnamed class?

痞子三分冷 提交于 2019-11-28 19:08:30
Is there a way to declare a constructor or a destructor in an unnamed class? Consider the following void f() { struct { // some implementation } inst1, inst2; // f implementation - usage of instances } Follow up question : The instances are ofcourse constructed (and destroyed) as any stack based object. What gets called? Is it a mangled name automatically assigned by the compiler? Vlad from Moscow You can not declare a constructor or destructor for an unnamed class because the constructor and destructor names need to match the class name. In your example, the unnamed class is local. It has no

Define local function in JavaScript: use var or not?

天涯浪子 提交于 2019-11-28 16:38:12
When a local (inner) function is declared in JavaScript, there are two options: Declaring with var keyword, assigning to the variable: (function() { var innerFunction1 = function() { ... }; innerFunction1(); }()); Declaring just with the function keyword, without assigning to variable: (function() { function innerFunction2() { ... }; innerFunction2(); }()); I can see one advantage of the second: the function can be declared below the code which calls it so it is easier to separate private functions from the code actually executed. Which of them is better and why ? Selvakumar Arumugam Actually

How to create an Array, ArrayList, Stack and Queue in Java?

a 夏天 提交于 2019-11-28 15:50:45
问题 I was reading a Java article, but found no differences in the declaration and was confused over. Can anyone list me out this? Added the Article http://www.theparticle.com/javadata2.html 回答1: Without more details as to what the question is exactly asking, I am going to answer the title of the question, Create an Array: String[] myArray = new String[2]; int[] intArray = new int[2]; // or can be declared as follows String[] myArray = {"this", "is", "my", "array"}; int[] intArray = {1,2,3,4};