concept

Is it necessary to write else part in every if condition?

烈酒焚心 提交于 2019-12-06 18:01:31
问题 The question I asked might be closed, But i just want to know that is it necessary to write else part of every if condition. One of my senior programmer said me that "you should write else part in every if condition" . Suppose we have no condition for write in else part then what should we do ? I assume a healthy discussion will going on here.... 回答1: That's a horrible idea. You end up with code of the form: if (something) { doSomething(); } else { } How anyone could think that's more

Is NULL a pointer?

一个人想着一个人 提交于 2019-12-05 10:30:42
So, I had an argument with my professor earlier defending that NULL is not a pointer, but he kept on insisting that it is because there is such a thing as NULL pointer. So, here I am now a little bit confused if NULL is really a pointer or not I already tried search over the internet but couldn't find any answer, so my last resort is here In C, NULL is a macro that expands to a null pointer constant. 7.19p3 The macros are NULL which expands to an implementation-defined null pointer constant; ... A null pointer constant is an integer constant expression with the value 0 ( e.g., 0 , 1-1 , 42*0LL

Is it necessary to write else part in every if condition?

て烟熏妆下的殇ゞ 提交于 2019-12-04 23:25:23
The question I asked might be closed, But i just want to know that is it necessary to write else part of every if condition. One of my senior programmer said me that "you should write else part in every if condition" . Suppose we have no condition for write in else part then what should we do ? I assume a healthy discussion will going on here.... That's a horrible idea. You end up with code of the form: if (something) { doSomething(); } else { } How anyone could think that's more readable or maintainable that not having an else at all is beyond me. It sounds like one of those rules made up by

Timer Efficiency

守給你的承諾、 提交于 2019-12-04 13:53:14
问题 I am planning to develop a system with tens of thousands of objects in it, which will each have up to 42(but more likely down around 4 or 5) separate actions they will potentially be performing at regular intervals. I also plan to write code that will deactivate the timers until the object comes into use. When idle, the objects will only need 1 timer each, but when active, the other timers will all start at once. At first the number of objects will be small, maybe a few hundred, but I expect

Login system concept & logic?

眉间皱痕 提交于 2019-12-04 12:35:19
问题 I want to know the process which usually web apps follow to maintain login between multiple requests and also how they manage things using COOKIES. In my login form I am providing "Remember Me" feature. When user login then I check the username and password validity from database. If its valid then I check if "Remember me" is selected, if yes then storing username and password in session, encrypted format. And finally storing username and password in SESSION. When user navigates form one page

Why does same_as concept check type equality twice?

為{幸葍}努か 提交于 2019-12-03 23:52:34
Looking at the possible implementation of the same_as concept at https://en.cppreference.com/w/cpp/concepts/same_as i noticed something strange is happening. namespace detail { template< class T, class U > concept SameHelper = std::is_same_v<T, U>; } template< class T, class U > concept same_as = detail::SameHelper<T, U> && detail::SameHelper<U, T>; The first question is why a SameHelper concept is nedded? The second is why same_as checks if T is the same as U and U the same as T ? Isn't it redundant? Interesting question. I have recently watched Andrew Sutton's talk on Concepts, and in the Q

Login system concept & logic?

守給你的承諾、 提交于 2019-12-03 07:57:42
I want to know the process which usually web apps follow to maintain login between multiple requests and also how they manage things using COOKIES. In my login form I am providing "Remember Me" feature. When user login then I check the username and password validity from database. If its valid then I check if "Remember me" is selected, if yes then storing username and password in session, encrypted format. And finally storing username and password in SESSION. When user navigates form one page to another, first I run login check script which checks if there is any value in cookies, then it

Understanding C's fork() through a simple example

微笑、不失礼 提交于 2019-12-03 07:38:01
问题 #include <stdio.h> int num = 0; int main(int argc, char*argv[]){ int pid; pid = fork(); printf("%d", num); if(pid == 0){ /*child*/ num = 1; }else if(pid > 0){ /*parent*/ num = 2; } printf("%d", num); } I'm having trouble understanding why the possible outputs would be 0102 or 0012 or 0201 or 0021. Here is what I (think) it should be producing. It hits the first printf statement and no matter what child or parent gets executed first, num hasn't been modified so 0 first. THEN next is either 1

Python supports a limited form of multiple inheritance. In what way limited?

旧街凉风 提交于 2019-12-02 20:28:15
In the python tutorial it's said that " Python supports a limited form of multiple inheritance ". What are the limitations? Apart from @Matt Anderson's answer I think that the limitations is in fact for the old style classes (which the tutorial for Python 2.6 still addresses ). In the Python 3 tutorial the text is now: Python supports a form of multiple inheritance as well . I'm not sure to what limitations the author of the python tutorial was referring, but I would guess it has in part to do with the way that method / attribute lookup is implemented in python (the "method resolution order"

Unterstanding how Vaadin uses GWT

◇◆丶佛笑我妖孽 提交于 2019-11-30 19:02:40
After playing around with Vaadin for about a week I'm curious about how Vaadin uses GWT. GWT compiles Javacode to Javascript. This has to be done everytime when you are redeploying. Since Vaadin has to be understood as a server-centric framework, eliminating your flexibility on writing Code that is executed on Clientside and moving everything to the server (which sounds worse than it actually is), the GWT Compiler only runs once a time. For example this happens when you are importing a plugin from the vaadin website. But it can't be that easy right? If it only would compile the code of the