The Big Programming Thread - Page 265
| Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
|
Shield
Bulgaria4824 Posts
| ||
|
heishe
Germany2284 Posts
On March 08 2013 12:15 nunez wrote: why does 'done' have to be public for this to compile? class listener{Lambda expressions are basically global functions, even if you create them inside the scope of a class. Global functions don't have access to the private members of any class' object, so you need to make it public. If you want it to work with "done" still being private, you have to capture it in the "[]" of the lambda, so either "[&done]" to capture the variable manually by reference, or "[&]" to capture everything in the current scope by reference (you can capture it by value too, but considering the semantics of your class this would be nonsensical). | ||
|
memcpy
United States459 Posts
On March 08 2013 12:15 nunez wrote: why does 'done' have to be public for this to compile? class listener{Probably a compiler bug. Seems to work fine with using an initializer list. #include <atomic> | ||
|
memcpy
United States459 Posts
On March 08 2013 23:37 heishe wrote: Lambda expressions are basically global functions, even if you create them inside the scope of a class. Global functions don't have access to the private members of any class' object, so you need to make it public. If you want it to work with "done" still being private, you have to capture it in the "[]" of the lambda, so either "[&done]" to capture the variable manually by reference, or "[&]" to capture everything in the current scope by reference (you can capture it by value too, but considering the semantics of your class this would be nonsensical). That's not entirely correct. Lambda expressions are actually more like local classes and according to section 11/2 of the standard: "A local class of a member function may access the same names that the member function itself may access." Explained here: http://stackoverflow.com/questions/12731215/access-rights-of-a-lambda-capturing-this | ||
|
JonGalt
Pootie too good!4331 Posts
On March 07 2013 18:50 disco wrote: Did you install libapache2-mod-php5 and not just the php cli? (If you want to run php as a apache module that is, which I am assuming you do). Using a package manager (apt-get) makes your life so much easier. It will automatically update the configuration files for you as well. I do have this installed. The same problem persists and is rather annoying. Any ideas or suggestions? I am searching the web and trying to read up but still nothing. | ||
|
nunez
Norway4003 Posts
@memcpy yes, i tried using initializer list as well, and that worked. that was where i came from so to say. but with the lambda in it it looks so messy. same if it is within the constructor. it seems like if i use the il on each class variable it does not get access to the private / protected members of the class, but if it follows the constructor it does. which actually seems to be consistent with: "A local class of a member function may access the same names that the member function itself may access." thanks for replies. | ||
|
Yoshi-
Germany10227 Posts
On March 09 2013 00:16 JonGalt wrote: I do have this installed. The same problem persists and is rather annoying. Any ideas or suggestions? I am searching the web and trying to read up but still nothing. http://www.php.net/manual/en/install.unix.apache2.php See if steps 7 and 8 apply to your Config file from apache. | ||
|
Shield
Bulgaria4824 Posts
| ||
|
Frigo
Hungary1023 Posts
On March 05 2013 22:14 Frigo wrote: Speaking of non-blocking I/O, does anyone know the proper way to read an object from a java.nio.channels.SocketChannel? Assuming several clients and whose requests we would like to process as fast as possible. I've been thinking of two approaches: - Using a cached thread pool and start a receiver thread every time we notice incoming data. Receiver thread would just read an object and pass it to a queue. Not sure if it could work, the structure of SocketChannel and Socket would prevent - Preface each transmission with the size of the serialized object and do all object reads in 1 thread. This could potentially screw up the server if a malicious server sends large sizes and/or does not send the object. After some research and twiddling, I settled with Apache Mina. I made a thin wrapper over it that apart from connection handling, puts the incoming messages in a LinkedBlockingQueue so I can process them in a game loop. Here and here are the sources if anyone is interested. I recommend Apache Mina, it seemed the best of the message passing frameworks I have looked at. | ||
|
Arnstein
Norway3381 Posts
+ Show Spoiler +
When I run it I get a red arrow that points to the int wid = rand() % this->width; in the placeMines() function. It doesn't say anything more than that. | ||
|
Isualin
Germany1903 Posts
| ||
|
Arnstein
Norway3381 Posts
| ||
|
Isualin
Germany1903 Posts
| ||
|
nunez
Norway4003 Posts
consider this: #include <iostream>notice how this->b changes to 2 after getting set equal to the local variable b. also in placeMines() you only declare the variable a but you don't initialize it to any value. int a; edit: i'm not saying these are the only errors, i didn't look through it that closely. :> also:
will always woop() no matter what value the variable bool a has. step up your game arnstein. this is not what you should be having trouble with when you are learning about classes! | ||
|
heishe
Germany2284 Posts
On March 09 2013 00:16 memcpy wrote: That's not entirely correct. Lambda expressions are actually more like local classes and according to section 11/2 of the standard: "A local class of a member function may access the same names that the member function itself may access." Explained here: http://stackoverflow.com/questions/12731215/access-rights-of-a-lambda-capturing-this That's interesting. Thanks! | ||
|
Arnstein
Norway3381 Posts
![]() | ||
|
nunez
Norway4003 Posts
On March 10 2013 06:44 Arnstein wrote: Thanks a lot! I thought that since it was the same name of the variables, you could just do this->width ![]() if you have a struct a that has some variable b, then the variables name is not b, but rather a::b. | ||
|
Arnstein
Norway3381 Posts
On March 10 2013 06:54 nunez wrote: if you have a struct a that has some variable b, then the variables name is not b, but rather a::b. Of course, I should have understood that. Thanks for the help! Do you study engineering/informatics? If so, where? | ||
|
nunez
Norway4003 Posts
On March 10 2013 07:00 Arnstein wrote: Of course, I should have understood that. Thanks for the help! Do you study engineering/informatics? If so, where? aha, yes, you have found me out! i study cybernetics at ntnu. you? | ||
|
green.at
Austria1459 Posts
It's a simple problem and you can write/compile code in your browser in multiple languages. | ||
| ||
