Explanation of the specific code application of C ++ timer

Source: Internet
Author: User

The C ++ programming language has a lot of practical content that deserves our constant experience in practice to become proficient in the language to facilitate our actual development. Today we will bring you some application skills of C ++ timer. You can use this as a reference to master this application skill.

C ++ timer sample code:

 
 
  1. /this code is writen by c++  
  2. #include <iostream> 
  3. #include <ctime> 
  4. using namespace std;  
  5. class timer{  
  6. clock_t start;   
  7. public:  
  8. timer(); //set new time  
  9. ~timer(); //distory time() and get new time  
  10. };  
  11. timer::timer()  
  12. {  
  13. start = clock;  
  14. }  
  15. timer::~timer()  
  16. {  
  17. clock_t end;  
  18. end=clock();  
  19. cout << "Elapsed time:" << (end-start)/CLOCKS_PER_SEC << endl;  
  20. }  
  21. int main()  
  22. {  
  23. timer ob;  
  24. char c;  
  25. ob.timer();  
  26. //for()  
  27. //cin >> c;  
  28. return 0;  

The preceding section describes the C ++ timer application.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.