definition

name collision in C++

怎甘沉沦 提交于 2019-12-23 20:32:05
问题 While writing some code i came across this issue: #include <iostream> class random { public: random(){ std::cout << "yay!! i am called \n" ;} }; random r1 ; int main() { std::cout << "entry!!\n" ; static random r2; std::cout << "done!!\n" ; return 0 ; } When i try to compile this code i get the error error: ârandomâ does not name a type. When I use some different name for the class the code works fine. Seems like random is defined somewhere else(although the compiler message is not very

Why do structure definitions have internal linkage?

筅森魡賤 提交于 2019-12-23 15:39:39
问题 (I am talking about C, but it also applies to class templates in C++) In header file, it is a custom to put all the DECLARATIONS, not definitions. However, we usually put structure definitions or class templates in header file as well without actually knowing why we can. This doesn't really make sense because they are definitions as well -- ONE DEFINITION RULE. (Yes, structure definitions and class templates don't cause any storage to set, but you still get "redefinition" error below which

Pseudocode: a clear definition?

大憨熊 提交于 2019-12-23 11:46:35
问题 The following code is an example of what I think would qualify as pseudocode, since it does not execute in any language but the logic is correct. string checkRubric(gpa, major) bool brake = false num lastRange num rangeCounter string assignment = "unassigned" array bus['business']= array('person a'=>array(0, 2.9), 'person b'=>array(3, 4)) array cis['computer science']= array('person c'=>array(0, 2.9), 'person d'=>array(3, 4)) array lib['english']= array('person e'=>array(0, 4)) array rubric =

iOS alignment lost in merging tentative definition

China☆狼群 提交于 2019-12-22 17:48:54
问题 when I archive my iOS app I get the following errors: ld: warning: alignment lost in merging tentative definition _isDragging ld: warning: alignment lost in merging tentative definition _isLoading Could someone please tell me what's wrong and where should I look for... Thanks! 回答1: I just ran into this same issue. I'm assuming that _isDragging and _isLoading are global variables that you declared somewhere. If that is so, make sure you declare both as extern in your .h file thusly: MyFile.h

Linking issue with “multiple definition of” compilation error

五迷三道 提交于 2019-12-22 05:55:21
问题 I have the following "constants" header: /* constants.h */ #ifdef __cplusplus extern "C" { #endif #pragma once #ifndef CONSTANTS_H #define CONSTANTS_H const char * kFoo = "foo"; const char * kBar = "bar"; #endif #ifdef __cplusplus } #endif I am #include -ing this header in files X.c and Y.c . Note that I am not including this in X.h or Y.h . The files X.c and Y.c get compiled into object files which are archived into a static library called libXY.a . When I include X.h and Y.h in Z.h , and

Does this fit your definition of a Callback?

前提是你 提交于 2019-12-22 05:41:40
问题 Definition of Callback: A Function that is set as a property within a Component. And is usually called when some event occurs on the Component. For Example: If you wish to display a dialog which reads "I was clicked" when the user clicks on the Component componentB , you would write a method stored as a variable which does this: var mouseDownCallbackFunction = function() { alert("I was clicked!"); }; Next , you would set this function inside the component like so... // Set the Component to

Angular: why isn't $evalAsync called $applyAsync?

 ̄綄美尐妖づ 提交于 2019-12-22 05:37:06
问题 Angular beginner question about scopes (docs here). $eval executes an expression in the context of a scope. $apply basically calls $eval and then $digest . Why does $evalAsync call $digest too (or, more precisely, ensure $digest is called)? It seems to be that $ eval Async should really be called $ apply Async , doesn't it? I'm a beginner -- what am I missing? 回答1: $evalAsync and $applyAsync target to different situations. $evalAsync : defers the expression to the next loop iteration of

LISP - destructive and non-destructive constructs

谁都会走 提交于 2019-12-22 04:45:20
问题 What is the correct definition of destructive and non-destructive constructs in LISP (or in general). I have tried to search for the actual meaning but I have only found a lot of usage of these terms without actually explaining them. It came to my understanding, that by destructive function is meant a function, that changes the meaning of the construct (or variable) - so when I pass a list as a parameter to a function, which changes it, it is called a destructive operation, because it changes

What is a module in C++?

我的未来我决定 提交于 2019-12-22 03:48:57
问题 What does the term module refer to in the following sentence? Don't allow exceptions to propagate across module boundaries. This is rule 62 in C++ Coding Standards by Herb Sutter and Andrei Alexandrescu. I have now read the book, so I would like to quote the section summary, which I think adds some clarity: Don't throw stones into your neighbor’s garden: There is no ubiquitous binary standard for C++ exception handling. Don't allow exceptions to propagate between two pieces of code unless you

MySQL: how to prevent insertion of a row with all columns = NULL?

大兔子大兔子 提交于 2019-12-22 00:38:33
问题 In my MySQL table, every column by itself can be NULL, but there must be at least one column with a non-NULL value. At the moment, I am wrapping an insert statement in a stored procedure which prevents insertion of all-NULL rows, but that of course does not keep anyone from using native INSERT statements, circumventing my wrapper procedure. Is there a 'native' way to define the table with that constraint ? 回答1: Since MySQL doesn't enforce check constraints, you may want to emulate one with a