instances

This commit is contained in:
2020-03-28 14:45:55 +01:00
commit cc9ef0fd57
16 changed files with 254 additions and 0 deletions

1
cpp/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.out

20
cpp/instances/car.cpp Normal file
View File

@ -0,0 +1,20 @@
/*
Basic Car class
just here to make the demonstration in the main file possible
explanation of the code here will be given in later lessons
*/
#include "car.h"
#include <iostream>
#include <string>
using namespace std;
void car::print_info()
{
cout << "Car Information:" << endl;
cout << "- manufacturer: " << manufacturer << endl;
cout << "- model: " << model << endl;
}

20
cpp/instances/car.h Normal file
View File

@ -0,0 +1,20 @@
/*
Basic Car class
just here to make the demonstration in the main file possible
explanation of the code here will be given in later lessons
*/
#pragma once
#include <string>
using namespace std;
class car
{
public:
std::string manufacturer;
std::string model;
void print_info();
};

15
cpp/instances/main.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "car.h"
#include <cstring>
int main() {
car a;
a.manufacturer = "Benz";
a.model = "Velo";
car b;
b.manufacturer = "Ford";
b.model = "Model T";
a.print_info();
b.print_info();
}