Tuesday, May 18, 2010

About C / C++ / C#: Programmers Do Marketing?

If you can't see this email, click here

About.com

C / C++ / C#

Fundamentals

Tips & Tools

Going Pro



From David Bolton, your Guide to C / C++ / C#
I keep a weather eye on the computer book market and noticed an interesting new trend. Books that show you how to market your Apps for the App Store. I've got a couple on order so I'll take a look and review them. Although my brief is to educate about C, C++ and C# (now including Objective-C), I like to look at those languages not just from a purist programming language point of view but from how developers use them as well. That said, all three entries have some code in each! Have a great week!

What's New in Visual C++ Part 1
These are a few of the changes I'll cover others in later blog entries.

The auto keyword

In C++ this has an additional meaning the compiler uses the auto keyword to declare a variable from the right hand side of the = ; i.e. initializing expression.. The older meaning and the same as in C was that an auto variable was local to a function and you still needed the type. eg auto int result; It's use was in my experience pretty rare as it was the default storage type in functions. Now in C++ it tells the compiler go figure what type to use from the expression. This new use helps declarations with templates, pointers to functions, or pointers to members declarations, however it also works for simple types. Note that when you use auto you must provide an initializer. auto count=0; // int auto str="a"; // char and you can't use it to declare the return type of a function or method! By default this is the new meaning of the word.

Coding bug Caught by Yoda Is
In Star Wars, if Yoda talking is, things backwards spoken are, a bit like parts of German that I taught was. Yiddish is apparently similar and Yoda/Yiddish seems perhaps more than a coincidence. In coding you can do things a bit Yodaish for example: #include <stdio.h> int main(int argc, char* argv[]) {     int a=4;     if (4==a)        printf("A = 4");     return 0; } The if (4== a) is Yodaish and looks a bit odd but the expression is commutative, i.e. the order doesn't matter. It's quite sensible to put it this way round once you've got your head into reading it. if (a=4) compiles and runs even though it's a bug because it assigns the value 4 and teh expression has a true value. This is a compile error in C#. if (4=a) does not compile in C, C++ or C#. Yoda finds this bug in all three languages as a value can't be assigned a variable. Hurray for Yoda!

Optional Parameters in C# 4.0
In methods, optional parameters have existed in other programming language for quite a while; C++ and Delphi for instance. What makes them more interesting is that they aren't just for method arguments in C# 4.0, but for constructors, indexers, or delegates as well. This simple example shows it with three instances of the test class being called. the second using the default parameter of 5 and the third with a named parameter. using System.IO; namespace ConsoleApplication1 {     class test     {         public test(int Testval = 5)         {             System.Console.WriteLine("Value = {0}",Testval) ;         }     }     class Program     {         static void Main(string[] args)         {             test t = new test(6) ;             test t1 = new test() ;             test t2 = new test(Testval: 78) ;         }     } } The output is Value = 6> Value = 5 Value = 78

Welcome to the C Area with Articles about C Programming
The C Area is where all the articles about C Programming are found. Technical articles, source code, experiences, hints etc.

 


C / C++ / C# Ads
Featured Articles
Welcome to the C++ Area with Articles about C++ Development
Welcome to the C Sharp Area with Articles about C Sharp Development
Learn about Commercial Software Development
All about Games Programming
Code Library for C, Objective-C, C++ and C#
Development Projects from Initial Design to Completed Code

 

More from About.com

Disney Trip Planner
Everything you need to plan the perfect Disney vacation -- from when to go and what to do, to saving money and picking a hotel. More >



Join About.com's User Panel!
Share your opinions and help us make About.com more relevant, informative and enjoyable to use. More>




This newsletter is written by:
David Bolton
C / C++ / C# Guide
Email Me | My Blog | My Forum
 
Sign up for more free newsletters on your favorite topics
You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter. If you wish to change your email address or unsubscribe, please click here.

About respects your privacy: Our Privacy Policy

Contact Information:
249 West 17th Street
New York, NY, 10011

© 2010 About.com
 


Must Reads
Programming Challenges
About C, C++ and C#
C++ for Beginners
C++ Programming
Intro to OOP

Advertisement

No comments: