Remove unused code and migrate to CMake build system.

This commit is contained in:
2026-02-13 16:05:08 +01:00
parent b22b7f213f
commit 90fbcc38dc
25 changed files with 2662 additions and 16 deletions
+6
View File
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 4.1)
project(pointer)
set(CMAKE_CXX_STANDARD 20)
add_executable(pointer main.cpp ClassA.cpp)
+11
View File
@@ -0,0 +1,11 @@
#include "ClassA.h"
#include <iostream>
void ClassA::Print() {
std::cout << "ClassA" << std::endl;
}
int ClassA::CompareTo(IComparable *other) {
return 0;
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef POINTER_CLASSA_H
#define POINTER_CLASSA_H
#include "IComparable.h"
class ClassA : public IComparable {
// private
public:
// public
void Print();
int CompareTo(IComparable* other) override;
protected:
// protected
private:
// private
int _number = 0;
};
#endif //POINTER_CLASSA_H
+9
View File
@@ -0,0 +1,9 @@
#ifndef POINTER_ICOMPARABLE_H
#define POINTER_ICOMPARABLE_H
class IComparable {
public:
virtual int CompareTo(IComparable* other) = 0;
};
#endif //POINTER_ICOMPARABLE_H
+24
View File
@@ -0,0 +1,24 @@
#include "ClassA.h"
int main() {
ClassA a{};
a.Print();
ClassA *pA = nullptr;
pA = new ClassA();
pA->Print();
// (*pA).Print(); // same line as above, but more complex to write
delete pA;
pA = nullptr;
a.CompareTo(pA);
IComparable *pComparable = nullptr;
pComparable = new ClassA();
pComparable->CompareTo(pA);
// pA = dynamic_cast<ClassA *>(pComparable);
delete pComparable;
pComparable = nullptr;
return 0;
}