@RMartinhoFernandes I read in a book that they dont take any memory if you dont declate a variable from that enum type that've created, so for example : enum color{yellow=19,black=322,white=3,red=21}; so I can use them without storing any memory
@MooingDuck : Macro have to be replaced by the preprocessor, sothat the compiler will deal with the number not a variable but in the case of enumeration , the compiler must deal with them as variable so I guess they must have an address where they get stored , no ?
@AlexDan yeah, values like that are usually directly in the assembly/machine code
(or for languages that have bytecodes, it's in that)
int a = 5;
int b = 7;
int c = a + b; /*in assembly, it will grab two variables, add them and store in c*/
int d = a + 7; /*in assembly, it will grab one variable, add seven and store in d*/
//The seven is in the instructions, not in a variable.
Coin Toss
Write a program that allows the user to play the following game. The user specifies how many times to toss a coin, and guesses the number of times heads or tails will come out. If the user’s guess is right, he “wins”, otherwise he “loses”. The user should be able to continue playing th...
@RMartinhoFernandes now that I think on it, I recall how closely C mirrors hardware capabilities, and processors can't copy arrays as a single operation. ergo...
@MooingDuck there is some function, which already is defined, for example srand(), I want to try call it from #define exaclty, is it possible? or #define is only for definitions? may be there is some trick?
LOL, The Pirate Bay is literally trying to build SkyNet. Ars Technica's comment, "The airborne computers will reportedly be more difficult for law enforcement agencies to terminate."
> Alongside such takedown efforts, the content industry's lobbyists will likely pursue a legislative strategy, such as encouraging sympathetic legislators to ban GPS.
@MooingDuck Didn't think about that. I would expect balloons to be helpless against high wind. So not only will the failure rate be high, they'll tend to fail simultaneously.
COP 1334
Coin Toss
How to Submit: Upload your source file (Lastname_Firstname.cpp) to Angel.
Coin Toss
Write a program that allows the user to play the following game. The user specifies how many times to toss a coin, and guesses the number of times heads or tails will come out. If the user’s gue...
@user1131997 you're not allowed to show up and immediately link something and not discuss the question.
@Potatoswatter I'm so close to 10k rep! When I get there, will I have rights to bin posts too, or for that would I need to be a room owner of one or both rooms?
I remember my first flag. It had a weight of like 25 and was a completely disgusting picture. SO just proudly showed me this and declared that 25 others found it offensive. So confusing.
hmm, when I install our code from our install server, the file I'm working on is slightly different than when I build it locally, and it's different enough that I can't replace it. And I can't debug it. How can I test my changes? :(
So you remember back when they had those tutorial books that a kid could go through each chapter and learn something?
My 9-year old is interested in programming and I am looking for a book that has tutorials that teach C++. I have found many other good C++ books, but they tend to be too advanced...
oh, so you're taking a pointer to pointer to an array and treating it as an array of pointers to arrays. Whatever. You've written a template that only works with one argument type, and used it with a different type.
@user1131997 note the fact they didn't use *list[something], because that would dereference twice. I know very well how binary trees and pointers work.
> C++ for a 9 year old is the most bone-headed idea I have heard in a long time. If you want to make sure that your 9 year old will be terrified of programming for ever more, then this is the course to take. – David Heffernan 28 mins ago
@user1131997 that only works if t_array is of type T**. Is t_array of type T**? If not, then no, you can't do that code.
@user1131997 no, not using a template for print_data was a side comment, it was the last sentance. The error in your code is not to pass the pointer to print_data by reference when the function expects a pointer.
@user1131997 In the first one: void print_data(T *data), you're passing it a int**, which is obviously wrong. In the second one: void print_data(T data), you're passing it an int*, which works fine.
All of this would have been obvious to you if you used C++ instead of "C with templates"
i would like to implement dynamically changing performance tray icon in QT.
However i cant seem to find any relevant links on google,so do you have any ideas how to do this ? if you dont know what im asking for,ive created a gif file, where you ll get my idea.
So any links,codes,examples are appr...
@RMartinhoFernandes we stopped playing before the undead kicked in. At that point it was only kobold/goblins. You usually didn't get any sieges until year 5 or so.
It was accidental. I didn't notice they were stocking up the hospital with adamantine strands until it was too late. But I don't care, I have >500 (after equipping the soldiers).
@MooingDuck (*data)[i] - it helped, thanks a lot! really thanks very much! but don't understanding the syntax of C :( why should I put iterator-value outside the unreferenced-pointer :(
@user1131997 you have a pointer to an array. To get the array, you have to (*data). That gives you the array. Then you want the int in the i index, which is [i] of that array.
@user1131997 if you weren't giving the array a int**, you wouldn't have that problem. It would just be data[i].
@MooingDuck ahhh, may be you mean, that unrefenced, that some object is not set a reference to smth, it the dereference means, the process of getting the object on wich pointer references?
@user1131997 "dereferenced" means "grab the thing this pointer points at" "unreferenced" means "you never use this variable for anything whatsoever". The two words are not related.
int my_func(int a) {
char d; //unreferenced variable
return a+3;
}
> Java is a terrible programming language developed by incompetent programmers. It is not an undue exaggeration to say that everything Java does is wrong. There is nothing interesting that can be learned from Java, except how such an awful programming language can become so popular. Java is said to increase programmer productivity, but this is a half-truth. Java increases the productivity of incompetent programmers; it harms the productivity of excellent programmers.
> Since 90% of programmers are incompetent, the overall effect is that Java increases programmer productivity. I submit that this is the exact opposite of a good thing. Do not waste time with Java; let the incompetent programmers revel in their miserable language while you embrace the wonder that is C++.
which pattern can I use that allows only one instance of a class to execute an action, and forbid the other objects to execute this same action. E.g. lets say I have a class car, how can I specify to only one object to be allowed to open the car windows, and the other objects not. (I mean, withou flags). I think this is more about patterns than c++ itself, but I'm implementing it with C++.
@rogcg he's saying you have one global "open_window_action" that is owned by at most one car at a time. It keeps track of it's owner, and a car must own it to open windows
@rogcg Look, if you only want object x to call methods on y, then you pass a (pointer to y) to x, and not to other objects. Then only x will be able to call methods on y.
@rogcg it can be done without flags, but it's very very complicated, and depends on what tasks are being done in what order and how they all interrelate