Skip to content

OSU-CS162-W17/class-basics

Repository files navigation

Class basics

This repo contains some code demonstrating the basics of C++ classes. You can find class declarations in the .hpp files and class implementations in the corresponding .cpp files.

There are a few different examples here, each in a different set of files:

  • point.hpp and point.cpp contain the interface and implementation of a basic class representing a point in 2D space. This class demonstrates some of the most basic essentials of C++ classes, including the syntax for declaring and implementing a class and its methods, the different types of class constructors, accessors, and mutators, etc. There is an application in point-stuff.cpp that demonstrates basic class usage using this Point class.

  • student.hpp and student.cpp contain the interface and implementation of a class representing a student. This class demonstrates some of more advanced class essentials, especially ones related to classes that use dynamically allocated members. When you have a class like this, you typically need to implement a copy constructor, an assignment operator, and a destructor, as we do for the Student class. There is an application in student-stuff.cpp that demonstrates the usage of this class.

You can compile this code using the provided makefile and then run it as follows:

make
./point_stuff
./student_stuff

You can also run the command make clean to clean up the directory of files generated by compilation.

About

Some basics of C++ classes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published