Advertisement
obernardovieira

Same struct in two .cpp files

Sep 6th, 2013
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. //main.cpp
  2.  
  3. #include <iostream>
  4. #include "next.hpp"
  5.  
  6. extern carro Carrao;
  7.  
  8. int main() {
  9.     saida();
  10.     std::cout << Carrao.rodas << std::endl;
  11.     Carrao.rodas = 10;
  12.     std::cout << Carrao.rodas << std::endl;
  13.     saida();
  14.     std::cout << Carrao.rodas << std::endl;
  15.     system("pause");
  16.     return 1;
  17. }
  18.  
  19. //next.cpp
  20.  
  21. #include <iostream>
  22. #include "next.hpp"
  23.  
  24. carro Carrao;
  25.  
  26. void saida() {
  27.     Carrao.rodas = 5;
  28. }
  29.  
  30. //next.hpp
  31.  
  32. #ifndef NEXT_HPP
  33. #define NEXT_HPP
  34. struct carro {
  35.     int rodas;
  36.     int portas;
  37. };
  38.  
  39. void saida();
  40. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement