So when I pass a const char * to a functiononce, I cannot use it again? It ends up spitting out crap to me?
const char *config_file = "file.txt";
function(int x, config_file);
cout << "Number" << x;
secondfunction(int y, config_file);
Do I need to make a pointer to config_file...
@soldieraman: I don't think that actually has anything to do with C++; most software on Windows relies on the VC runtime libraries, regardless what language it is written in.
but i thought assert would only run under debug code
assert prints a diagnostic message when expression evaluates to false (0) and calls abort to terminate program execution. No action is taken if expression is true (nonzero). The diagnostic message includes the failed expression and the name of the source file and line number where the assertion failed.
After debugging is complete, assertion checking can be turned off without modifying the source file by defining the identifier NDEBUG. NDEBUG can be defined with a /D command-line option or with a #define directive. If NDEBUG is defined with #define, the directive must appear before Assert.h is included.
I need to calculate the 2 angles (yaw and pitch) for a 3D object to face an arbitrary 3D point. These rotations are known as "Euler" rotations simply because after the first rotation, (lets say Z, based on the picture below) the Y axis also rotates with the object.
This is the code I'm using bu...
I can't use Boost ASIO (reasons not related to programming) and I looked around and libcurl looks good. I'm building the binaries at the moment and decided to get some feedback from the community.
Any comments regarding libcurl/alternatives?
UPDATE:
libcurl's not great for telnet. It's 2010! S...
@GMan - okay, now currently here's wot i do: - calculate a rotation matrix once per object based on 3 angles, X, Y, Z - use this matrix to transform all points of my 3d object
okay so if you want me to use quaternions I'm going to need code that can calculate a rotation matrix from a quat? .... I tried this before but it does not product wot i call "local rotations"
@Jenko In your problem you could first find a quaternion, that makes the rotation between V1 and V2 (vectors) and the decompose that quaternion into heading, pitch and roll.
I should add, however, that contrary to claim, it was not discovered by MS in the late '80s. I actually experienced it once (though I think the BAC was higher than he gives). A friend of mine and I went to the "Hall Inn", got "comfortable", so to speak, went back and wrote a fairly completely multiplayer game (in Fortran), then went and passed out.
When we came to, there were all these new files neither of us clearly remembered, but the first time we tried it (at least that we could remember clearly) the code ran essentially perfectly!
I doubt there is a really good answer. On comp.lang.c++, there are a few people who put in quite a bit of time writing answers that point at the FAQ (if memory serves, Neil was among them at one time).
Personally, I rarely did/do though; IMO, the C++ FAQ (and most others) tends to generalize too much, and tries to condense answers too much, so it doesn't take into account what are often a pretty wide range of reasonable answers.
Chatting with Neil would be awesome. Someone would be like "So when I do int i;, what's the value of i?" "You nitwit, you never initialized it. What C++ book taught you that? Maybe read closer next time!"
@sbi: that's not surprising. I should point out, however, that Neil departed comp.lang.c++ a few different times, at least IIRC. For that matter, I've done the same a few times -- when you're more tempted to write a flame than a useful answer, it's time to spend more time doing other things for a while.
Neil was actually pretty polite about things. A few of he denizens of comp.lang.c (and even comp.lang.c.moderated) used to be much nastier. Unfortunately (speaking of my age) I can't remember most of their names anymore.
The big problem I see is that you just about have to write the questions specifically to use as FAQs. Most real questions will ask some subset of the real question, or ask it in a way that you pretty much need to be an expert to realize that 1) it is a FAQ, and 2) there's one answer to roughly 10,000 variations that the people who need ti won't recognize are really the same.
@sbi: Yeah, I was just thinking that too, since that can only be edited by... well, fewer people. We already have a few questions linked from there too, I think.
Yes, I think this should be discussed on meta before we pull it off. I also think the question starting this should be asked on SO first, then moved to meta. And I think it should be asked about 10am PST. :)
@JerryCoffin Definitely. But you could also take good candidates and change them to become FAQs.
@JerryCoffin I agree, but a good set of FAQ questions can also help make it easier for those who frequent the C++ tag to point people in the right direction. I know that I have trouble finding duplicates sometimes.
I think SO is a very good place to prevent this from happening. But we might need more support infrastructure from SO to do this. Like the possibility to close a question as an FAQ dupe, pointing to the right FAQ question. We might not need this right from the start, but once this system is established, it might be relatively easy to get this feature. This is why I think this whole idea should be discussed at meta. People in other tags might have the same idea, after.
@neversaint: yes. Basically, this takes 1, shifts it left N places, which gives a 1 followed by N zeros. It then subtracts one, which produces N 1's with zeros to the left of that.
it seems to me, just having someone go through archives linking to 'good' questions would be a viable strategy, so as to keep stackoverflow.com/tags/c%2b%2b/faq in good order.
@sbi: what exactly did you plan to ask on meta? I'm kind of thinking in the direction @goldPseudo just suggested -- link to existing questions, and possibly write/answer/link to new ones where there isn't a suitable FAQ, to ensure everything on that page really is a FAQ.
The big disadvantage I see is when that page runs out of space, there doesn't seem to be a pointer to the "next most linked questions"...
@JerryCoffin (I linked to that chat entry, but it's now gone through the roof.) Basically James and I thought of taking this discussion we're leading here to meta. I thought of doing at around 10am PST, because the C++ tag is nicely crowded around that time. Also I meant to ask on SO first, then have the question moved to meta, so it gets more exposure to the C++ crowd on SO.
just browsing through stackoverflow.com/questions/199333/… (the last one on the FAQ list), i don't see a single stackoverflow link going /from/ the question or answers, yet it still has 11 'linked'.
i think the 'linked' is bidirectional. either links to or from are listed.
not sure if adding the questions to the tag wiki would count as a 'link', but it's as good a place to start as any.
The real problem I came upon is that make_unique<Object>(...parameters for Object's constructor...) can theorically use any constructing/destructing idiom (not necessarly new/delete) ; but in practice you have to know in advance the type of the deleter because it's in the unique_ptr's template parameter
This is not a problem for trivial destructors (like destroyBar) but it gets more complicated when you use std::bind, std::mem_fun or a lambda for example
@goldPseudo The link from the tag wiki would be one link. If even the least linked to question has a dozen already, I don't think this would change much.
Also, as was said before, there's only so much question to be listed on that page. And they will not be in a nice order. You cannot group them by theme. How are you going to find anything in there?
@sbi If there aren't even a dozen questions (either in the archive or newly asked) that can be relevantly linked to a question, it probably isn't "Frequently asked" in the first place.
@goldPseudo That's what that page is good for. It lists questions that are frequently linked to. It does not, however, help you to find out whether a question you are about to ask was already asked and has a good, definitive, approved-by-the-high-rep-regulars answer.
No, you should. The value of the lambda expression can persist, the lambda expression itself shouldn't.
I guess to state what I've failed to more succinctly: Try not to put yourself in a position where you need to repeat the lambda expression. If you do, it should probably be made into it's own functor for repeated use.
In general, though, you're already doing too much. Do one thing, either manage a single resource or use multiple resources to do a single task. You're managing multiple resources, or managing a single resource and using others. That's bad.