declaration

Should I consider that declaring all C static functions is a good practice? [closed]

旧城冷巷雨未停 提交于 2019-12-12 10:49:26
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . I recently wrote a piece of C code like that: static void func1() { } static void func2() { } typedef void (*func_t)(void); const func_t lookUpTable[FUNC_COUNT] = { [FUNC1] = &func1, [FUNC2] = &func2 } An other programmer worked on the same file and changed it to: static void

- Default value of variables at the time of declaration -

强颜欢笑 提交于 2019-12-12 09:47:01
问题 I was wondering what were the default values of variables before I initialized them... For example, if I do : //myClass.h BOOL myBOOL; // default value ? NSArray *myArray; // default value ? NSUInteger myInteger; // default value ? Some more examples here : //myClass.m // myArray is not initialized, only declared in .h file if ([myArray count] == 0) { // TRUE or FALSE ? // do whatever } More generally, what is returned when I do : [myObjectOnlyDeclaredAndNotInitialized myCustomFunction];

GOTO before local variable

耗尽温柔 提交于 2019-12-12 08:18:08
问题 Does the following piece of code constitute undefined behaviour, since I am jumping before the variable declaration and using it via a pointer? If so, are there differences between the standards? int main() { int *p = 0; label1: if (p) { printf("%d\n", *p); return 0; } int i = 999; p = &i; goto label1; return -1; } 回答1: There is no undefined behavior in your program. goto statement has two constraints: (c11, 6.8.6.1p1) "The identifier in a goto statement shall name a label located somewhere

default value of a variable at the time of declaration in C# and VB?

蓝咒 提交于 2019-12-12 07:12:57
问题 Can anybody tell me what is the default value of a variable at the time of declaration in C# and vb?? 回答1: In c# you can use the default keyword to determine default values. For example: default(bool) default(int) default(int?) 回答2: Do you mean a (method) variable? or a field (on an instance or type)? For a method-level variable (in C# at least) it is irrelevant, since "definite assignment" means that you must give it a value before you can read it. Fields default to the bitwise zero state:

C++ class declaration and include issues in gsoap project

心不动则不痛 提交于 2019-12-12 05:52:10
问题 I compile a file in a gsoap project with the following command. Almost all files in my project are generated by the gsoap tools and i am new to C++ so i cant tell very much about it. All in all i need to understand if my project could compile at all. Do i need other flags? gcc -c -I/usr/include/gsoap soapAuftraegeImportSoap11BindingProxy.cpp the current error is: soapAuftraegeImportSoap11BindingProxy.cpp:10: error: 'AuftraegeImportSoap11BindingProxy' has not been declared this line 10 is:

Friend function not declared in this scope error

自闭症网瘾萝莉.ら 提交于 2019-12-12 04:58:00
问题 Hi I am trying to understand the scope of friend functions and I get a "not declared in scope" error. Here is my code: //node.h class Node{ public: int id; int a; int b; friend int add(int,int); void itsMyLife(int); Node(); }; //node.cpp Node::Node(){ a=0; b=0; id=1; } void Node::itsMyLife(int x){ cout<<"In object "<<id<<" add gives "<<add(x,a)<<endl; } //routing.cpp #include "node.h" int add(int x, int y){ return x+y; } //main.cpp #include "node.h" int main(){ return 0; } I get the error

Understanding of “inline” in C++ class constructor? [duplicate]

情到浓时终转凉″ 提交于 2019-12-12 04:14:30
问题 This question already has answers here : In C++ can constructor and destructor be inline functions? (5 answers) Closed 2 years ago . I read a source code of class address_v4 in boost library and there are several constructors declared with BOOST_ASIO_DECL (defined as inline) /// Construct an address from raw bytes. BOOST_ASIO_DECL explicit address_v4(const bytes_type& bytes); /// Construct an address from a unsigned long in host byte order. BOOST_ASIO_DECL explicit address_v4(unsigned long

What kind of Makefile variable assignment is this?

浪子不回头ぞ 提交于 2019-12-12 02:33:10
问题 I've used simple makefiles for years, but only recently been assigned the task of learning the ins and outs of a large, complicated set of Autotools-generated makefiles which is used for a code base my employer has bought. In these, I'm running into variable declarations like the following: QOBJECT_MOCSRCS = $(QOBJECT_HEADER:%.h=.gen/moc_%.cpp) \ $(QOBJECT_SRCS:%.cpp=.gen/moc_%.cpp) QOBJECT_DEPS = $(QOBJECT_MOCSRCS:%.cpp=.deps/%.Po) My best guess from context is that these set up lists of

Laravel: Undefined variable

家住魔仙堡 提交于 2019-12-12 01:53:34
问题 im having a problem with my code. I want to show the record of the student who login but im having an undefined variable on my view.blade Here's my Model class Attendance extends Eloquent { public function users() { return $this->belongsTo('User', 'id'); } } Here's my Controller public function viewstudentAttendance() { $students = Auth::user()->id; //load view and pass users return View::make('student.view') ->with('attendances', $students); } Finally here's my view.blade @extends('layouts

C function definition and declaration

血红的双手。 提交于 2019-12-12 01:16:35
问题 I'm a Java programmer,I learnt a little C++ and now I'm studying a little C for my job. I can't understand C behaviour about function declaration/definition and related function calls. From K&R I know that in C (very different from C++) I can call a function that has not been previously declared,and the compiler assumes an implicit declaration of the type: int main() { function(10); // implicit function declaration ( int function() ) } and I know that such a declaration implies a function