Jambix64

FuncaoArgumentoPadrao

Jul 14th, 2016
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  using namespace std;
  4.  // Argumentos padrão para uma função;
  5.  int boxVolume(int length =1, int width = 1, int height =1); // funcao pré definida
  6.  
  7.   int main(){
  8.      
  9.       cout<<boxVolume();// funcao pre definida, deixa a funcao ser inicializada com parametros vazios;
  10.       cout<<boxVolume(1)<<endl;
  11.       cout<<boxVolume(10,20)<<endl;
  12.       cout<<boxVolume(10,20,30)<<endl;
  13.       system("pause");
  14.     return 0;
  15.   }
  16.  
  17.  
  18. int boxVolume(int length , int width , int height){ //  e aqui podemos trabalhar com seus argumentos;
  19.    
  20.     return length + width  + height;
  21. }
  22. // Erro comum de programação especificar  argumentos padrão no protótipo e no cabeçalho da função
  23.  
  24. // Operador de soluçao de escopo unario ::
Add Comment
Please, Sign In to add comment