Skip to content

Instantly share code, notes, and snippets.

@Doubble29x
Created August 2, 2024 00:02
Show Gist options
  • Save Doubble29x/56e084e86a565b5e6a6163eac75a49c8 to your computer and use it in GitHub Desktop.
Save Doubble29x/56e084e86a565b5e6a6163eac75a49c8 to your computer and use it in GitHub Desktop.
Some refresh on classes, childs & templates
#include <iostream>
#include "operations.h"
int main()
{
g_add<int> ADD;
ADD.SumNums(10000, 100);
std::cout << "Size of ADD object \n" << sizeof(ADD.getsize) << std::endl;
aChild childFunction;
childFunction.SumNums(10, 100);
flag = true;
isSummer("htwhtww");
}
#ifndef OPERATIONS_H_INCLUDED
#define OPERATIONS_H_INCLUDED
static bool flag = false;
template <typename T>
class g_add {
public:
uint32_t test;
uint32_t *getsize = &test;
void SumNums(T n1, T n2) {
std::cout << "The sum of " << n1 << " + " << n2 << " is " << n1+n2;
}
};
class aChild: public g_add<int> { // Child function (g_add)
public:
int x = 10;
};
template <typename T>
void isSummer(T flag) {
std::cout << "\nSummer flag is : " << flag << std::endl;
}
#endif // OPERATIONS_H_INCLUDED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment