Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C/C++

C/C++ C/C++ Discussion

Reply
 
Thread Tools Display Modes
Old 12-16-2005, 02:40 PM   #1 (permalink)
Myrrdin
Guest
 
Posts: n/a
Default C/C++ complete references.

the first book is for C++, while it is the fourth edition it is still very very useful...

C++: The Complete Reference, 4th Edition (Paperback)
by Herbert Schildt
ISBN: 0072226803
Comments: thick book, good for tossing at people, but seriously, it's great for those who just want strait forward explanations on things and also references... excellent for those who are wanting to go ahead and just learn conventions.

C: The Complete Reference, 4th Ed. (Paperback)
by Herbert Schildt
ISBN: 0072121246
Comments: same as above, but for C... couple this with the above and you got a solid understanding of C/C++

notes:
1) on both of these with how Micros**t does it's things they might nto work work 100% if your using C, but if you use Mingw32 you will be set.

2) these two books focus on general C/C++ programming but do not go into heavy details on standardized scripts... but it's still useful.
  Reply With Quote
Old 12-16-2005, 04:01 PM   #2 (permalink)
Master of the Internet
 
DontdroptheSOAD's Avatar
 
Join Date: Apr 2003
Location: Glen Saint Mary, Florida
Age: 19
Posts: 6,834
Send a message via AIM to DontdroptheSOAD
Default

?? Notice the only other thread in this forum is for posting books @_@
__________________

Robin Lovett
April 21, 1948 - March 12, 2007
DontdroptheSOAD is offline   Reply With Quote
Old 12-16-2005, 04:44 PM   #3 (permalink)
Forum Newbie
 
Join Date: Nov 2002
Posts: 89
Default

Programming in Objective-C

Stephen G. Kochan
punt59 is offline   Reply With Quote
Old 12-20-2005, 03:03 PM   #4 (permalink)
Administrator
 
Zippy's Avatar
 
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,845
Default

Believe me I know all things C/C++... If you wanna know something other than books, just ask :-P
__________________
Zippy, Razor Creator and RunUO Core Developer
The RunUO Software Team

"Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal."
~The Cryptonomicon

Zippy is online now   Reply With Quote
Old 12-20-2005, 03:40 PM   #5 (permalink)
Forum Expert
 
arul's Avatar
 
Join Date: Jan 2005
Location: Hiding in your room.
Age: 21
Posts: 1,272
Send a message via MSN to arul
Default

Quote:
Originally Posted by Zippy
Believe me I know all things C/C++... If you wanna know something other than books, just ask :-P
Ok, Zippy, I'm a bit confused with enums in C++.
Code:
#include <iostream>

using namespace std;

enum PeopleFlags { 
    None =      0x00,
    HasCar =    0x01,
    HasPet =    0x02,
    HasWife =   0x04,
    HasHouse =  0x08,
    HasGarden = 0x10
};

int main()
{
    PeopleFlags mask = (PeopleFlags)5;
    cout << mask;
    cin.get();
    return 0;
}
So, the problem is, why does it return 5, my presumption is it should return 8.
Btw. sorry for a small thread-hijack :-/
__________________
arul is offline   Reply With Quote
Old 12-20-2005, 05:10 PM   #6 (permalink)
Forum Expert
 
Join Date: Aug 2004
Location: Redmond, WA
Age: 21
Posts: 1,288
Send a message via AIM to Sep102 Send a message via MSN to Sep102
Default

Essentially, enums are merely ints with a different type and that type is implicitly convertible to int but does not include a "conversion constructor" for int(which is why int i = None; works whereas PeopleFlags pf = 5; does not). Therefore it would make sense that you could assign any value that can fit in an int to an enum and have the enum hold that value, as it is only an abstracted int.

With that said, it makes sense that the conversion is applied between PeopleFlags and int is applied when you output it to stdout, as there is no operator << defined with right-hand parameter of PeopleFlags, and seeing as how all the conversion does is return the value held rather than the closest value defined in the enum (or some other such thing), 5 is output.

Also, the values in the enum's definition are just that, values assigned to that identifier, not the only values that an object with type of the enum can hold, however they are one of the only things that can be assigned to an object of that enum without a cast.



And, getting back to the thread's topic, if I were to recommend a core subset of books to read, I'd have to suggest

For C:
The C Programming Language by Brian W. Kerninghan and Dennis M. Ritchie

For C++:
The C++ Programming Language by Bjarne Stroustrup
The C++ Standard Library : A Tutorial and Reference by Nicolai M. Jusuttis
C++ Templates: The Complete Guide by Nicolai M. Josuttis and Daveed Vandevoorde
C++ Primer by Stanley B. Lippman, Josée Lajoie and Barbara E. Moo
Imperfect C++ by Matthew Wilson

And other than those, I'd also recommend most of the books from the C++ In-Depth series as well as the Effictive * line of books by Scott Meyers.

Other than that, practice, practice and more practice. Experience is the best teacher once you can grasp the basics.

Last edited by Sep102; 12-20-2005 at 05:30 PM.
Sep102 is offline   Reply With Quote
Old 12-20-2005, 05:44 PM   #7 (permalink)
Forum Expert
 
arul's Avatar
 
Join Date: Jan 2005
Location: Hiding in your room.
Age: 21
Posts: 1,272
Send a message via MSN to arul
Default

Nice, thanks for great explanation Sep, I grow on the enums in C#, so this was a little shock for me
__________________
arul is offline   Reply With Quote
Old 12-23-2005, 09:48 PM   #8 (permalink)
Administrator
 
Zippy's Avatar
 
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,845
Default

Basically enums in C++ are just ints. Don't think of them as having any other special properties... they are just ints and they define constants. Depending on the compiler very little checking is done on enum types other than the checks for integers....

So something like

Code:
enum Color { Blue, Red };
enum Size { Big, Small };

Color mycolor = Big;
may work without any complaints on some compilers.

Unlike C#, C/C++ compilers vary widely about exactly how they do things, even between compilers which are also ANSI.
__________________
Zippy, Razor Creator and RunUO Core Developer
The RunUO Software Team

"Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal."
~The Cryptonomicon

Zippy is online now   Reply With Quote
Old 12-26-2005, 04:31 PM   #9 (permalink)
Forum Expert
 
Join Date: Aug 2004
Location: Redmond, WA
Age: 21
Posts: 1,288
Send a message via AIM to Sep102 Send a message via MSN to Sep102
Default

Quote:
Originally Posted by Zippy
may work without any complaints on some [C] compilers.
I agree with you with that addition to your statement, as most, if not all newer C++ compilers (at least ones that I know of) would not allow that to happen seeing as how C++ introduced new typing rules to give it much stronger typing that C has.

For example, enums (normally) have much more type information associated with them than they did in C, so there is a good chance that a C++ compiler (or C/C++ compiler compiling under C++) would not allow that statement at all or at the very least emit a warning that the two types are not exactly the same and it may not be what your intentions were.

Last edited by Sep102; 12-26-2005 at 04:43 PM.
Sep102 is offline   Reply With Quote
Old 01-08-2006, 04:18 PM   #10 (permalink)
xir
Forum Newbie
 
Join Date: Jul 2004
Posts: 59
Default

Exceptional C++ by Herb Sutter is a book for more advanced users of C++. It provides the does and don't of C++/STL, engineering designs and "safe" coding by presenting puzzles to the reader and then offers an in-dept solution and discussion of the problem/puzzle. It is very good reading.

The infamous GoF book, no developer should be without this in his repertoire. Design Patterns - Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides.

Another book you can't go without :- Modern C++ Design: Generic Programming and Design Patterns Applied By Andrei Alexandrescu

A copy of the real C++ standard in hardback if you have spare cash lying around is probably a good investment too. Although you can find drafts of the standard online, it is more a vanity purchase than something you'd really use. Just something to say "Yeah I got that."


UNIX Network Programming Volumes by Richard Stevens if you can afford it and are network inclined (although might be a bit dated)
Donald E. Knuth, The Art of Computer Programming (one of the classics) again very expense since it encompases loads of volumes.

Algorithms by Robert Sedgewick is a pretty good algorithms book too.


The one I'm currently reading which is also a good read.
Refactoring: Improving the Design of Existing Code by Martin Fowler.

For C, "The C programming language" - the famous "K&R" book so many C programmers swear by. Again really a vanity purchase but good if you want to learn C. Make sure to get the latest edition though or else you'll be programming from C like they did 20 years ago ;/


That's all I can think of the moment :>

Last edited by xir; 01-08-2006 at 04:21 PM.
xir is offline   Reply With Quote
Old 06-01-2006, 12:15 PM   #11 (permalink)
 
Join Date: Aug 2005
Location: Woodward, OK
Age: 34
Posts: 67
Default

Quote:
Originally Posted by Zippy
Believe me I know all things C/C++... If you wanna know something other than books, just ask :-P
Oh yeah? How are ya with Win32 API?
wreckage is offline   Reply With Quote
Old 06-01-2006, 01:03 PM   #12 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
Default

WIN32API = easy MSDN tells all about it and how to use it with great explinations
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 06-01-2006, 03:31 PM   #13 (permalink)
 
Join Date: Aug 2005
Location: Woodward, OK
Age: 34
Posts: 67
Default

Quote:
Originally Posted by Sorious
WIN32API = easy MSDN tells all about it and how to use it with great explinations
Oh I agree completely very easy.. except when it doesn't behave right. Here's the problem I'm having:

I'm using Visual C++ Express
I've created a DLL for a global hook
I've tried this with both the GetMessage hook and the standard Mouse hook

In both cases I'm met with the same results. I'm simply trying to catch when someone right clicks on a forms minimize button. Naturally I'm watching for the WM_NCRBUTTONUP message to accomplish this. What happens is truly odd indeed. When the hooks are in place the hook doesn't trigger properly when I click the minimize button. If I click dead center or to the left of dead center on the minimze button with my right mouse button I get a system menu. If I click to the right of dead center over almost to the right border of the minimize button then my hook triggers properly but only far over to the right edge of the button. I've tested this with the maximize button and close button and they both function properly. Also if I use the left mouse button on my minimize button everything performs as expected. The only time this happens is in MY code and with the RIGHT MOUSE button.

Got any ideas? I can attach my projects if you need them.
wreckage is offline   Reply With Quote
Old 06-01-2006, 04:10 PM   #14 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
Default

Quote:
Originally Posted by wreckage
Oh I agree completely very easy.. except when it doesn't behave right. Here's the problem I'm having:

I'm using Visual C++ Express
I've created a DLL for a global hook
I've tried this with both the GetMessage hook and the standard Mouse hook

In both cases I'm met with the same results. I'm simply trying to catch when someone right clicks on a forms minimize button. Naturally I'm watching for the WM_NCRBUTTONUP message to accomplish this. What happens is truly odd indeed. When the hooks are in place the hook doesn't trigger properly when I click the minimize button. If I click dead center or to the left of dead center on the minimze button with my right mouse button I get a system menu. If I click to the right of dead center over almost to the right border of the minimize button then my hook triggers properly but only far over to the right edge of the button. I've tested this with the maximize button and close button and they both function properly. Also if I use the left mouse button on my minimize button everything performs as expected. The only time this happens is in MY code and with the RIGHT MOUSE button.

Got any ideas? I can attach my projects if you need them.
I R C++ illiterate , i just know the WIN32API from C# You should start another thread asking for help here tho, im sure someone will come along who can help
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5