41 lines
1004 B
C
Raw Permalink Normal View History

2020-05-03 15:12:03 +02:00
// #pragma once is usually included in header files to make sure they are only loaded once
// it's a simpler version of include guards, which are necessary to prevent conflicts
#pragma once
/*
in case #pragma once is not supported by your compiler you'll need more basic include guards
in this case it would be
#ifndef car_h
#define car_h
...class contents
#endif
*/
// including a necessary library and namespace to work with strings
#include <string>
using namespace std;
// define the class
class car
{
// define the visibility of the following fields and methods
// in this case everything is public since visibility is a topic in future lessons
public:
2020-05-04 19:24:16 +02:00
// define two fields, manufacturer and model
2020-05-03 15:12:03 +02:00
std::string manufacturer;
std::string model;
2020-05-04 19:24:16 +02:00
// define a method that will print out information
2020-05-03 15:12:03 +02:00
void print_info();
};
/*
That completes the header file, as you can see, there are no implementations in here.
That's because they will be added in the car.cpp file.
*/