instances
This commit is contained in:
1
cpp/.gitignore
vendored
Normal file
1
cpp/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.out
|
20
cpp/instances/car.cpp
Normal file
20
cpp/instances/car.cpp
Normal 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
20
cpp/instances/car.h
Normal 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
15
cpp/instances/main.cpp
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user