#include<iostream>

using namespace std;

struct Base{
 virtual void print(){cout << "Base"<< endl;}
};
 
struct Derrived : Base{
  void print(){cout << "Derrived"<< endl;}
};

template< Base* arr,int size = 10>
class Template{
public:
 void print(){arr->print();}
};
#include "template.h"
 
int main(){

 Base *b = new Base();
 Derrived *d = new Derrived();
 Template<b>  baseParam;
 
return 0;
}

Why does this doesn't compile:

Template<b>  baseParam;

Thank you!

wehat error arer you getting. also when you define a template you would normaly use the syntax

template <typename T, typename C>
class Template
{
       //...
};

change this :

template< Base* arr,int size = 10>

to

template<typename Type,int size = 10>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.