Created
October 11, 2019 20:40
-
-
Save PatrikValkovic/50329975f86e0328ff1f85fda17a23f3 to your computer and use it in GitHub Desktop.
This file contains 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
// Example program | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
template<typename T> | |
class A | |
{ | |
public: | |
template<typename U> | |
class B; | |
/* | |
class D : public B<int> | |
{ | |
public: | |
void method2() { | |
cout << "Method 2" << endl; | |
this->method1(); | |
} | |
}; | |
*/ | |
class D; | |
}; | |
template<typename T> | |
template<typename U> | |
class A<T>::B | |
{ | |
public: | |
void method1() { | |
T x; | |
cout << "Method 1: " << x << endl; | |
} | |
}; | |
template<typename T> | |
class A<T>::D : public A<T>::B<int> | |
{ | |
public: | |
void method2() { | |
cout << "Method 2" << endl; | |
this->method1(); | |
} | |
}; | |
int main() | |
{ | |
A<int>::D b; | |
b.method2(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment