Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 957 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
957
Dung lượng
3,53 MB
Nội dung
[...]... Review of the OOP Constructs in C+ + 687 Using Classes as Data Members 688 Accessing Classes in Classes 689 Inheriting in C+ + 689 Building a Base Class for Inheritance 690 The Protected Access Data Modifier 692 Inheriting from a Base Class 693 Constructors and Destructors Revisited 696 xviii Sams Teach Yourself C in 21 Days A Caution on What... systems He has developed systems using such tools as C, C# , C+ +, XML, SQL Server, PowerBuilder, Visual Basic, Active Server Pages (ASP), Satellite Forms, and more Jones’s other authoring credits include Sams Teach Yourself Advanced C in 21 Days (Sams Publishing) and Sams Teach Yourself C# in 21 Days (Sams Publishing) PETER AITKEN has been writing about computers and programming for over 10 years, with some... Defining and Declaring Structures 250 Accessing Members of a Structure 251 Using Structures That are More Complex 254 Including Structures Within Other Structures 254 Structures That Contain Arrays 257 Arrays of Structures 260 Initializing Structures 263 Structures and Pointers 266 Including Pointers as Structure Members 266 Creating... strcpy() Function 483 The strncpy() Function 485 The strdup() Function 486 Concatenating Strings 487 Using the strcat() Function 487 Using the strncat() Function 489 Comparing Strings 490 Comparing Two Entire Strings 491 Comparing Partial Strings 493 Comparing Two Strings While Ignoring Case 494 Searching Strings... each argument, there must be a conversion specifier The format string can also contain escape sequences The following are examples of calls to printf() and their output: Sams Teach Yourself C in 21 Days , 2 Example 1 #include int main( void ) { printf( “This is an example of something printed!”); } Example 1 Output This is an example of something printed! Example 2 printf( “This prints a character,... Classes 674 Controlling Access to Data in a Class 675 Setting the Access Type on Class Data 677 Creating Access Member Functions 680 Structures Versus Classes 683 Housekeeping with Classes 684 Starting with Constructors 684 Ending with Destructors 684 Using Constructors and Destructors 684 Function Overloading Revisited ... C+ + and the programming technique called object-oriented programming Perhaps you’re wondering what the differences are between C and C+ + and whether you should be teaching yourself C+ + instead of C Not to worry! C+ + is a superset of C, which means that C+ + contains everything C does, plus new additions for object-oriented programming If you do go on to learn C+ +, almost everything you learn about C. .. tools included on the CD In fact, because this book is written with the ANSI standard in mind, you can use any standard C compiler and editor The best way to learn a computer language involves more than just reading a book; it involves entering and running a number of programs The many C programs included in this book offer hands-on training If you are interested in cutting corners, you will find most... what else you can make it do The Type & Runs are for you to experiment with We hope you have fun playing with these additional code listings! 3 4 Sams Teach Yourself C in 21 Days The CD-Rom and the Book’s Code For your convenience, the code listings in this book are available on the included CDROM As a bonus, the CD-ROM includes a couple of compilers Appendix G, “Getting Started with Dev -C+ +” shows you... Dev -C+ + compiler which is also included on the CD-Rom Errata and updates to the source code, if any, will be placed on the Internet for you to access at http://samspublishing.com Conventions Used in This Book This book uses different typefaces to help you differentiate between C code and regular English, and also to help you identify important concepts Actual C code appears in a special monospace font . Development Cycle 10 Creating the Source Code 10 Compiling the Source Code 12 Linking to Create an Executable File 13 Completing the Development Cycle 13 Your First C Program 16 Entering and Compiling. Working with C+ + Classes and Objects 665 Working with Complex Data in C+ + 666 Using Functions with Structures 667 Using Classes 674 Controlling Access to Data in a Class 675 Setting the Access. Function 486 Concatenating Strings 487 Using the strcat() Function 487 Using the strncat() Function 489 Comparing Strings 490 Comparing Two Entire Strings 491 Comparing Partial Strings 493 Comparing