Advertisement
jacknpoe

Guerreiros

Oct 8th, 2013 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <string.h>
  5.  
  6. using namespace std;
  7.  
  8. class cGuerreiros{
  9. public:
  10.     string nome;
  11.     static cGuerreiros combater( cGuerreiros guerreiro1, cGuerreiros guerreiro2);
  12. };
  13.  
  14. cGuerreiros cGuerreiros::combater( cGuerreiros guerreiro1, cGuerreiros guerreiro2)
  15. {
  16.   return ( ( rand() % 2) == 1) ? guerreiro1 : guerreiro2;
  17. }
  18.  
  19. int main( void){
  20.     cGuerreiros g1, g2;
  21.  
  22.     srand ( time( NULL));
  23.  
  24.     g1.nome = "Ricardo";
  25.     g2.nome = "Rodrigo";
  26.     cout << (cGuerreiros::combater( g1, g2)).nome;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement