A
Alex@L
I've a problem with following simple code (not really usefull):
//---------------------------------------------------------------------------
#pragma hdrstop
#include "stdio.h"
#include <iostream>
enum eTest1{et1_1, et1_2} e1;
enum eTest2{et2_1, et2_2} e2;
class ImageBase
{
public:
int rows;
int columns;
};
template <eTest1 EN1, typename eTest2 EN2>
//template <int EN1, typename eTest2 EN2>
class Image : private ImageBase
{
public:
Image()
{
rows=1;
columns=1;
std::cout<<"std CTOR"<<std::endl;
// use 'columns' and 'rows'
}
void out(){std::cout<<columns<<" "<<rows<<std::endl;};
};
template <eTest1 EN1>
//template <int EN1>
class Image<EN1, et2_2> : private ImageBase
{
public:
Image()
{
rows=500;
std::cout<<"columns, 200 CTOR"<<std::endl;
// use 'columns' columns and 200 rows.
}
void out(){std::cout<<columns<<" "<<rows<<std::endl;};
};
int main(int argc, char* argv[])
{
Image<et1_1, et2_1> img1;
img1.out();
Image<et1_1, et2_2> img2;
img2.out();
return 0;
}
//---------------------------------------------------------------------------
I't seem like the partial template specialization work not with my
Borland C++ Builder 5. I got the same behaviour with img1 and img2.
Some CTOR's and some out()-functions are called in both casses.
But if I use templates with ...int... it works fine.
Can somebody, please, explain me, what goes here wrong.
Thx, Alexander
//---------------------------------------------------------------------------
#pragma hdrstop
#include "stdio.h"
#include <iostream>
enum eTest1{et1_1, et1_2} e1;
enum eTest2{et2_1, et2_2} e2;
class ImageBase
{
public:
int rows;
int columns;
};
template <eTest1 EN1, typename eTest2 EN2>
//template <int EN1, typename eTest2 EN2>
class Image : private ImageBase
{
public:
Image()
{
rows=1;
columns=1;
std::cout<<"std CTOR"<<std::endl;
// use 'columns' and 'rows'
}
void out(){std::cout<<columns<<" "<<rows<<std::endl;};
};
template <eTest1 EN1>
//template <int EN1>
class Image<EN1, et2_2> : private ImageBase
{
public:
Image()
{
rows=500;
std::cout<<"columns, 200 CTOR"<<std::endl;
// use 'columns' columns and 200 rows.
}
void out(){std::cout<<columns<<" "<<rows<<std::endl;};
};
int main(int argc, char* argv[])
{
Image<et1_1, et2_1> img1;
img1.out();
Image<et1_1, et2_2> img2;
img2.out();
return 0;
}
//---------------------------------------------------------------------------
I't seem like the partial template specialization work not with my
Borland C++ Builder 5. I got the same behaviour with img1 and img2.
Some CTOR's and some out()-functions are called in both casses.
But if I use templates with ...int... it works fine.
Can somebody, please, explain me, what goes here wrong.
Thx, Alexander