-
-
Save Doubble29x/56e084e86a565b5e6a6163eac75a49c8 to your computer and use it in GitHub Desktop.
Some refresh on classes, childs & templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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