|
|
|
|
Re: I Learn Some Basic C++! [message #392448 is a reply to message #391886] |
Fri, 26 June 2009 19:18 |
HTT-Bird
Messages: 11 Registered: June 2009
Karma: 0
|
Recruit |
|
|
SSnipe: Grab "Accelerated C++" by Andrew Koenig and Barbara Moo. That should get you much further than anything I can post in this thread. Once you've worked through that book, you will have a good enough grasp of the language to start playing with Rene-coding.
@SK: Go read "The String Formatters of Manor Farm" by Herb Sutter. That, and we're getting varadic templates in C++0x, so expect to see something >>>> printf soon. Hint:
#include <cstdio>
int main()
{
const char* bad = "this will blow up";
int very = 42;
std::printf("%s%d\n", very, bad);
return 0;
}
With a varadic-template-enabled version of printf, you'd get a compiler error saying "can't convert int to const char*" not Undefined Behavior (translation: crash bang boom) at runtime.
|
|
|
Re: I Learn Some Basic C++! [message #392518 is a reply to message #392448] |
Sat, 27 June 2009 06:58 |
|
jnz
Messages: 3396 Registered: July 2006 Location: 30th century
Karma: 0
|
General (3 Stars) |
|
|
HTT-Bird wrote on Sat, 27 June 2009 03:18 | SSnipe: Grab "Accelerated C++" by Andrew Koenig and Barbara Moo. That should get you much further than anything I can post in this thread. Once you've worked through that book, you will have a good enough grasp of the language to start playing with Rene-coding.
@SK: Go read "The String Formatters of Manor Farm" by Herb Sutter. That, and we're getting varadic templates in C++0x, so expect to see something >>>> printf soon. Hint:
#include <cstdio>
int main()
{
const char* bad = "this will blow up";
int very = 42;
std::printf("%s%d\n", very, bad);
return 0;
}
With a varadic-template-enabled version of printf, you'd get a compiler error saying "can't convert int to const char*" not Undefined Behavior (translation: crash bang boom) at runtime.
|
Even more reason to be a stupid programmer! I've had my fair share of mismatched format strings, but due to the fact your program will blow up at runtime and the debugger usually catches it make this quite a silly thing to impliment. A lot of the "new" C++ features a simply going to add more bloat, slower code and features, like the one above. That are useless. I personally would like to see more behaviour defined, like default calling conventions. Or even just things like i++ + i--;, even if that is trivial. Another thing would be vtable manipulation, the order of the vtable in derived classes (that have pure or non-pure virtual functions) should be another thing. Redirecting the vtable in some cases can be quite useful. As far as I know, the pointer to the table is not even defined. It could be at any offset to the instance pointer too.
|
|
|
Re: I Learn Some Basic C++! [message #392533 is a reply to message #391886] |
Sat, 27 June 2009 09:50 |
|
futura83
Messages: 1285 Registered: July 2006 Location: England
Karma: 0
|
General (1 Star) Viva la Resistance! |
|
|
Or be lazy and disregard the BODMAS rules altogether and do the calculations you want in the order you do them.
As in, assign another variable, and do the calculation in stages.
Instead of 100 * (a + b + c)....etc, add:
double f;
f = a + b + c;
f *= 100;
That way your calculations are done in the order you write them, without having an understanding of BODMAS.
P.S. This is from an A-level maths student who has no trouble with BODMAS as well.
Edit: If you really don't like brackets in your example, simply do:
100 * a + 100 * b....etc....
This is a signature. Reading this is wasting your time.
[Updated on: Sat, 27 June 2009 09:51] Report message to a moderator
|
|
|
Re: I Learn Some Basic C++! [message #392551 is a reply to message #391886] |
Sat, 27 June 2009 11:50 |
_SSnipe_
Messages: 4121 Registered: May 2007 Location: Riverside Southern Califo...
Karma: 0
|
General (4 Stars) |
|
|
thanks for tips guys, i know im dumb to get confussed on the order of how to do the muliplication, but you say do the order, so i guesss that means the first number i want anythign done wioth i should put into brackets then lets say * 100? but does it matter which direction u right the code? like
<< (a + b + c) *100
or
<< 100 * (a + B + c)
and lets pretned the answer is 2000 which one will come out with the right one? is
|
|
|
|
|
|
Re: I Learn Some Basic C++! [message #392632 is a reply to message #392624] |
Sat, 27 June 2009 20:57 |
raven
Messages: 595 Registered: January 2007 Location: Toronto, Ontario
Karma: 0
|
Colonel |
|
|
Doitle wrote on Sat, 27 June 2009 22:11 | Also SK I dont know why but even in my EE classes when doing C++ they have us using CIN and COUT... not printf and scanf...
|
That makes me sad. Really.
-Jelly Administrator
-Exodus Administrator
|
|
|
|
Re: I Learn Some Basic C++! [message #393191 is a reply to message #393156] |
Tue, 30 June 2009 12:19 |
_SSnipe_
Messages: 4121 Registered: May 2007 Location: Riverside Southern Califo...
Karma: 0
|
General (4 Stars) |
|
|
Sir Kane wrote on Tue, 30 June 2009 10:12 |
raven wrote on Sat, 27 June 2009 22:57 |
Doitle wrote on Sat, 27 June 2009 22:11 | Also SK I dont know why but even in my EE classes when doing C++ they have us using CIN and COUT... not printf and scanf...
|
That makes me sad. Really.
|
Very sad, indeed. They possibly do that because it's "easy to use". With printf/scanf you have to remember all the format options, but once you get used to them, it's awesome.
|
I stopped reading the book for like 4 or 5 days since i had chores and job interviews and shit and learning some Spanish, im read it again today since im free in just a little bit tbh, but i think printf and scanf is next to learn..I saw it bringing it up so im guessing its next...but
I had an idea of a very simple console program I want to try next, Iv been learning Spanish, and all the words and there English translations i written down, I want to write a small consol thing so it ask me "what does this word mean in Spanish" and if i type it incorrect it will tell me, and only ask me the words i type in the code (the only workds i know) kind alike flash cards just the lazy way but that wont be untill a while
|
|
|
|
Re: I Learn Some Basic C++! [message #394204 is a reply to message #394203] |
Tue, 07 July 2009 01:32 |
_SSnipe_
Messages: 4121 Registered: May 2007 Location: Riverside Southern Califo...
Karma: 0
|
General (4 Stars) |
|
|
reborn wrote on Tue, 07 July 2009 01:11 | So how's it going?
|
I have not gotten far, honeslty summers been busy. im on like page 20 something, not far at all, but im start reading it soon, but learning Spanish, summer school, my new job, summer chores, and my girl & the gym, have been keeping my busy, i have not done c++ nor Spanish in over a week....so once i get my new job schedule, im find a way to fit it all in since as of this whole week my whole week was unpredictable
|
|
|
|
Re: I Learn Some Basic C++! [message #396852 is a reply to message #396851] |
Sun, 02 August 2009 14:35 |
_SSnipe_
Messages: 4121 Registered: May 2007 Location: Riverside Southern Califo...
Karma: 0
|
General (4 Stars) |
|
|
reborn wrote on Sun, 02 August 2009 14:26 | So how's it going?
By even Chapter five you should be able to start seeing how you could incorperate this stuff into renegade.
|
I have not gotten any furture since my last post, iv been flooded...working 9 hours a day. plus 2 for transportation, summer school, chores, church, cleaning, and ya, but once summer school ends im start reading where i left off at (it ends in 1 more week!)
|
|
|