From the course: Learning C++
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Solution: Create some classes - C++ Tutorial
From the course: Learning C++
Solution: Create some classes
(upbeat music) - [Instructor] Here's my solution. The records.CPP file starts by including the .H file. This is important because that file contains the function prototypes, and next, notice that the constructors are simply assigning the arguments to the member variables. You can see the constructor for the student class in line three and the constructor for the course class in line 14. And the getter functions are even simpler. They just return the member variable they're supposed to return. They are all one-liners. Here you can see the constructor and getter functions for the grade class. Now let's look at the test code in codedemo.cpp. Starting at line nine, I'm creating one object for each class. We have student number one named Hilda Jones. We have course number seven named physics 101 with four credits, and we have a grade, which is for student number one, Hilda, at course number seven, physics, and she got…
Contents
-
-
-
-
-
(Locked)
Structures2m 29s
-
(Locked)
Classes6m 47s
-
(Locked)
Using classes2m 1s
-
(Locked)
Header and implementation files4m 12s
-
(Locked)
Using several source files6m
-
(Locked)
Pointers5m 17s
-
(Locked)
Using objects with pointers4m 21s
-
(Locked)
References4m 25s
-
(Locked)
Vectors3m 35s
-
(Locked)
Using objects with vectors2m 45s
-
(Locked)
Challenge: Create some classes1m 32s
-
(Locked)
Solution: Create some classes1m 48s
-
(Locked)
-
-
-
-