Add .gitignore and IntelliJ IDEA project configuration files and projects for cpp intro, pointers and classes

This commit is contained in:
2026-02-13 12:19:53 +01:00
commit bd50c5403f
34 changed files with 1226 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 4.1)
project(classes)
set(CMAKE_CXX_STANDARD 20)
add_executable(classes
main.cpp
ClassA.cpp
)
+12
View File
@@ -0,0 +1,12 @@
#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 CLASSES_CLASSA_H
#define CLASSES_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 //CLASSES_CLASSA_H
+9
View File
@@ -0,0 +1,9 @@
#ifndef CLASSES_ICOMPARABLE_H
#define CLASSES_ICOMPARABLE_H
class IComparable {
public:
virtual int CompareTo(IComparable* other) = 0;
};
#endif //CLASSES_ICOMPARABLE_H
+17
View File
@@ -0,0 +1,17 @@
#include "ClassA.h"
int main() {
ClassA a;
a.Print();
ClassA* pA = nullptr;
pA = new ClassA();
pA->Print();
// (*pA).Print(); // same as above, but more complex to write
delete pA;
pA = nullptr;
a.CompareTo(pA);
return 0;
}