remove duplicate code
This commit is contained in:
@ -8,4 +8,4 @@ to be initialized with the keyword 'new'.
|
||||
|
||||
Relevant Files:
|
||||
|
||||
- [main.cpp](./main.cpp)
|
||||
- [main.cpp](./classes/main.cpp)
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
|
||||
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;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
|
||||
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();
|
||||
};
|
@ -1,20 +0,0 @@
|
||||
#include "car.h"
|
||||
#include <cstring>
|
||||
|
||||
int main() {
|
||||
// create a new car and store it in the variable 'a'
|
||||
// in contrast to java, c++ does not need initialization with the 'new' keyword here.
|
||||
car a;
|
||||
// set some data for that car
|
||||
a.manufacturer = "Benz";
|
||||
a.model = "Velo";
|
||||
|
||||
// do the same for a second car
|
||||
car b;
|
||||
b.manufacturer = "Ford";
|
||||
b.model = "Model T";
|
||||
|
||||
// use a function of the car class to print out the information
|
||||
a.print_info();
|
||||
b.print_info();
|
||||
}
|
Reference in New Issue
Block a user