declaration

Component is part of the declaration of 2 modules

一个人想着一个人 提交于 2019-11-27 05:03:22
问题 I try to build an ionic 2 app. When I try the app in the browser with ionic serve or launch it on an emulator everything works fine. But when I try to build it every time the error ionic-app-script tast: "build" Error Type AddEvent in "PATH"/add.event.ts is part of the declarations of 2 modules: AppModule in "PATH"/app.modules.ts and AddEvent in "PATH"/add-event.module.ts. Please consider moving AddEvent in "PATH"/add-event.ts to a higher module that imports AppModule in "PATH"/app.module.ts

Declaring and initializing a variable in a Conditional or Control statement in C++

时光毁灭记忆、已成空白 提交于 2019-11-27 04:58:57
In Stroustrup's The C++ Programming Language: Special Edition (3rd Ed) , Stroustrup writes that the declaration and initialization of variables in the conditionals of control statements is not only allowed, but encouraged. He writes that he encourages it because it reduces the scope of the variables to only the scope that they are required for. So something like this... if ((int i = read(socket)) < 0) { // handle error } else if (i > 0) { // handle input } else { return true; } ...is good programming style and practice. The variable i only exists for the block of if statements for which it is

Assign multiple values to array in C

陌路散爱 提交于 2019-11-27 04:29:17
问题 Is there any way to do this in a condensed form? GLfloat coordinates[8]; ... coordinates[0] = 1.0f; coordinates[1] = 0.0f; coordinates[2] = 1.0f; coordinates[3] = 1.0f; coordinates[4] = 0.0f; coordinates[5] = 1.0f; coordinates[6] = 0.0f; coordinates[7] = 0.0f; return coordinates; Something like coordinates = {1.0f, ...}; ? 回答1: If you really to assign values (as opposed to initialize ), you can do it like this: GLfloat coordinates[8]; static const GLfloat coordinates_defaults[8] = {1.0f, 0.0f

Declaration or Definition in C

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 04:22:07
问题 From External Variables Wiki: If neither the extern keyword nor an initialization value are present, the statement can be either a declaration or a definition. It is up to the compiler to analyse the modules of the program and decide. I was not able to fully grasp the meaning of this statement with respect to C. For example, does it imply that: int i; is not necessarily a declaration (as I have been assuming until now), but could be a definition as well (by definition of Definition &

Semicolon after class declaration braces

两盒软妹~` 提交于 2019-11-27 03:26:53
In C++ classes, why the semi-colon after the closing brace? I regularly forget it and get compiler errors, and hence lost time. Seems somewhat superfluous to me, which is unlikely to be the case. Do people really do things like: class MyClass { . . . } MyInstance; I get it from a C compatibility point of view for structs and enums, but since classes aren't part of the C language I guess it's primarily there the keep consistency between similar declaration constructs. What I was looking for was more related to design rationale rather than being able to change anything, although a good code

Has the new C++11 member initialization feature at declaration made initialization lists obsolete?

怎甘沉沦 提交于 2019-11-27 03:00:38
With C++11, we now have the ability to initialize class members in a header declaration: class aClass { private: int mInt{100}; public: aClass(); ~aClass(); }; So I'm a bit confused. Traditionally initialization lists in constructors have been used for member initialization: aClass::aClass() : mInt(100) { ... } Has the new C++11 member initialization feature at declaration made initialization lists obsolete? If not, what are the advantages of one over the other? What situations would make initialization at declaration advantageous, or initialization lists advantageous? When should one be used

Strange array return type

倖福魔咒の 提交于 2019-11-27 02:28:37
问题 Has any one seen the array [] placed after the method signature like this? public static String mySplit(String s)[] { return s.split(","); } public static void main(String... args) { String[] words = mySplit("a,b,c,d,e"); System.out.println(Arrays.toString(words)); } prints [a, b, c, d, e] In the past, odd notations have been for "C" compatibility, but I wouldn't imagine someone writing this in C either. Does anyone know why this is even allowed? I am using Java 7 update 10, in case it

Benefits of declaring a function as “inline”?

家住魔仙堡 提交于 2019-11-27 02:25:21
问题 Every time I read about the "inline" declaration in C it is mentioned that it is only a hint to the compiler (i.e. it does not have to obey it). Is there any benefit to adding it then, or should I just rely on the compiler knowing better than me? 回答1: There are two reasons to use the inline keyword. One is an optimization hint, and you can safely ignore it; your compiler is like to ignore it too. The other reason is to allow a function to exist in multiple translation units, and that usage is

Is Type(::x); valid?

孤者浪人 提交于 2019-11-27 01:48:59
问题 While discussing the Type(identifier); syntax and how it's a declaration, I came across Type(::x); not working with Clang. I would expect that given a global variable x , it would treat ::x as an expression ( ::x + 2 works) and cast ::x to Type . However, it gives a compiler error. Here is a short example: int x; int main() { int(::x); //does not compile int(::x + 2); //compiles } The compiler error given by Clang 3.5 is: error: definition or redeclaration of 'x' cannot name the global scope

Can a union be initialized in the declaration?

六月ゝ 毕业季﹏ 提交于 2019-11-27 01:42:30
For example, say we have a union typedef union { unsigned long U32; float f; }U_U32_F; When a variable of this union type is declared, is there a way to set an initial value? U_U32_F u = 0xffffffff; // Does not work...is there a correct syntax for this? Use an initializer list: U_U32_F u = { 0xffffffff }; You can set other members than the first one via U_U32_F u = { .f = 42.0 }; Try U_U32_F u = {0xffffffff}; Note that per-member union initialization doesn't work on pre-C99 compilers, of which there is a depressing number out there. The current Microsoft C compiler doesn't support it, for