Main Menu


Sponsored Links

  


  
  
Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next

Functions with Multiple Parameters

The syntax for declaring and invoking functions with multiple parameters is a common source of errors. First, remember that you have to declare the type of every parameter. For example:

void PrintTime ( int iHour, int iMinute )

{

// these will be concatenated just fine

// because there is at least one string

// in every + operation

ShowText ( iHour + ":" + iMinute );

}

It might be tempting to write (int iHour, iMinute), but that format is only legal for variable declarations, not for parameters.

Another common source of confusion is that you do not have to declare the types of arguments when calling the function. The following is wrong!

int iHour = 11;

int iMinute = 59;

PrintTime (int iHour, int iMinute); // WRONG!

In this case, the compiler can tell the type of hour and minute by looking at their declarations. It is unnecessary and illegal to include the type when you pass them as arguments. The correct syntax is:

int iHour = 11;

int iMinute = 59;

PrintTime ( iHour, iMinute);


Contents Previous Next
  
News

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi

...

Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat

...

Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.

...

Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal

...

read more news...


Poll