OOP HomeWork
This commit is contained in:
14
oop_hw1/oop_hw1_2/main.cpp
Normal file
14
oop_hw1/oop_hw1_2/main.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <iostream>
|
||||
#include "print_this.h"
|
||||
#include "print_that.h"
|
||||
extern int print_count;
|
||||
|
||||
int main() {
|
||||
#ifdef DO_THIS
|
||||
print_this("Hello");
|
||||
#else
|
||||
print_that("Hello");
|
||||
#endif
|
||||
std :: cout << "Print called " << print_count << " times." << std::endl;
|
||||
return 0;
|
||||
}
|
7
oop_hw1/oop_hw1_2/print.cpp
Normal file
7
oop_hw1/oop_hw1_2/print.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
#include "print.h"
|
||||
int print_count = 0;
|
||||
void print(const std::string& s) {
|
||||
++print_count;
|
||||
std::cout << s << std::endl;
|
||||
}
|
6
oop_hw1/oop_hw1_2/print.h
Normal file
6
oop_hw1/oop_hw1_2/print.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#ifndef PRINT_H
|
||||
#define PRINT_H
|
||||
void print(const std::string& s);
|
||||
#endif
|
5
oop_hw1/oop_hw1_2/print_that.cpp
Normal file
5
oop_hw1/oop_hw1_2/print_that.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "print.h"
|
||||
#include "print_that.h"
|
||||
void print_that(const std::string& s) {
|
||||
print("That: " + s);
|
||||
}
|
7
oop_hw1/oop_hw1_2/print_that.h
Normal file
7
oop_hw1/oop_hw1_2/print_that.h
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#ifndef PRINT_THAT_H
|
||||
#define PRINT_THAT_H
|
||||
void print_that(const std::string& s);
|
||||
#endif
|
5
oop_hw1/oop_hw1_2/print_this.cpp
Normal file
5
oop_hw1/oop_hw1_2/print_this.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "print.h"
|
||||
#include "print_this.h"
|
||||
void print_this(const std::string& s) {
|
||||
print("This: " + s);
|
||||
}
|
6
oop_hw1/oop_hw1_2/print_this.h
Normal file
6
oop_hw1/oop_hw1_2/print_this.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#ifndef PRINT_THIS_H
|
||||
#define PRINT_THIS_H
|
||||
void print_this(const std::string& s);
|
||||
#endif
|
Reference in New Issue
Block a user