I have collected few of the features of both C and C++ here.
Like the ternary operator; most of the programmers are familiar with.
x = (y < 0) ? 10 : 20;However this can be used the other way.
(y < 0 ? x : y) = 20;i.e.
if (y < 0)y = 20;elsex = 20;Another feature is Resource Acquisition Is Initialization (RAII) which is often ignored by the programmers coming from non object oriented world i.e. C background.
Can you write a return statement in a function that returns void?
static void foo (void) { }static void bar (void) {return foo(); // Note this return statement.}int main (void) {bar();return 0;}Even you could write something like
static void foo() { return (void)"i'm discarded"; }The comma operator isn’t widely used. It can certainly be abused, but it can also be very useful. One of the most common use is
for (int i=0; i<10; i++, doSomethingElse()){/* whatever */}C99 has some awesome any-order structure initialization.
struct foo{int x;int y;char* name;};void main(){foo f = { .y = 23, .name = "awesome", .x = -38 };}Hidden features of x86 assembly Hidden features of C Hidden features of C++ Hidden features of C#Tags: C Programming, Programming Tips
Like What you See?Become one of the regulars by subscribing! You'll be the first to know when we add more great posts just like this. Join up by either RSS Feeds or Email Updates today!
There are No Comments to this post. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response
Leave a ReplyClick here to cancel reply.You must be logged in to post a comment.
News & UpdatesEnter your email address:CategoriesTutorialsC Programming TutorialsC++ Programming TutorialsC# Programming TutorialsObject Oriented ProgrammingMicrosoft Direct-X ProgrammingProgramming StylesData StructuresSource CodeC Programming Source CodeC++ Source CodeASPVisual Basic Source CodePHP Source CodeJavaJava ScriptBlogFree UtilitiesComputer BooksGeneral BooksProgramming BooksDatabasesWeb Design & DevelopmentComputer Science BooksCertification CentralGeneral SoftwareGraphics & IllustrationHardwareNetworking BooksFAQs Tutorial Categories TutorialsC Programming TutorialsC++ Programming TutorialsC# Programming TutorialsObject Oriented ProgrammingMicrosoft Direct-X ProgrammingProgramming StylesData StructuresSource CodeC Programming Source CodeC++ Source CodeASPVisual Basic Source CodePHP Source CodeJavaJava ScriptBlogFree UtilitiesComputer BooksGeneral BooksProgramming BooksDatabasesWeb Design & DevelopmentComputer Science BooksCertification CentralGeneral SoftwareGraphics & IllustrationHardwareNetworking BooksFAQs Popular Tags .NETAlgorithmsAppletArraysB-TreeBooksC#.NETC++ LibraryC++ ProgrammingCalculatorClassClassesC ProgrammingCSharpDatabaseData StructureDirectXExceptionFAQFAQsFile HandlingFunctionsGameGraphicsInheritanceJavaJavaScriptLoopsNetworkingObjectOpen SourceOverloadingPHP Source CodePointersPolymorphismProgrammingProgramming TipsSortingSource CodeStackStringsUtilitiesVisual Basic Source CodeWindowsWireless
Niciun comentariu:
Trimiteți un comentariu