Learn C++ Testing, Catch2 Framework, and Classes with Useful Tips

c testing and classes n.w
1 / 15
Embed
Share

"Explore C++ testing concepts, Catch2 framework tutorial, and class implementation in C++. Understand constructors, initialization, and user-defined functions. Enhance your C++ skills with practical examples and helpful resources."

  • C++
  • Testing
  • Catch2
  • Classes
  • Constructors

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. C++ Testing and Classes G Carl Evans

  2. Catch2 Catch is a testing framework for C++ it is used in many places including in the CS225. The tutorial is here https://github.com/catchorg/Catch2/blob/master/docs/tutorial.md#top

  3. How hard was forth code review assignment? A. Easy B. Moderate C. Challenging D. Unreasonable

  4. How long did fourth assignment take? A. Less than 3 hours B. 3 to 6 hours C. 6 to 9 hours D. 9 to 12 hours E. More than 12 hours

  5. Things start doing Get C++ (Xcode/Visual Studio/gcc) Make a helloworld.cpp program and build it.

  6. Classes in C++ File layout .h Declare structure of the object including member variables Declare member functions (methods) .cpp Define functions of the class

  7. Constructors Run when an object is created before the object is available to make the object exist in a coherent state. Automatic Default Constructor Automatic Default: created by the compiler Default: takes no arguments Initializes member objects using their default constructor Non-object values undefined Only generated if no constructors written

  8. Constructors User Defined Functions with the same name as the class define constructors Initialization Lists Comma separated list member_variable_(expression) Run before the body of the constructor Default Arguments Provide values for missing agruments explicit StudentRecord(std::string name, int grade = 0); StudentRecord::StudentRecord(std::string name, int grade) : name_(name), grade_(grade) { //body }

  9. Gradebook class

  10. What System do you use for this class? A. Windows B. Macintosh C. Linux D. More than one of the above

  11. What development environment did you set up for C++? A. Visual Studio B. Xcode C. Editors and command line D. Other (Eclipse/Clion/???) E. What is a development environment?

  12. Operator Overloading Make code more readable and intuitive by allowing more natural expression Change the behavior of many of the standard operators based on the types that are being used. We have seen the overload of [] with map and vector We have seen the overload of -> and * with the iterator in map

  13. Operators that can be overloaded in C++ Operator Category Operators Arithmetic Bitwise Relational Logical Assignment + - * / % ++ -- & | ^ ~ >> << < <= > >= == != ! && || = += -= *= /= %= = &= |= >>= <<= <= >= () [] -> , -> Other

  14. Stream extraction and insertion std::ostream& operator<<(std::ostream& os, const T& obj){ // write obj to stream return os; } std::istream& operator>>(std::istream& is, T& obj){ // read obj from stream if( /* T could not be constructed */ ) is.setstate(std::ios::failbit); return is; }

  15. Student Record

Related


More Related Content