Skip to content

Instantly share code, notes, and snippets.

@PatrikValkovic
Created October 11, 2019 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrikValkovic/50329975f86e0328ff1f85fda17a23f3 to your computer and use it in GitHub Desktop.
Save PatrikValkovic/50329975f86e0328ff1f85fda17a23f3 to your computer and use it in GitHub Desktop.
// 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