Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

const and Templates

0 views
Skip to first unread message

Jose Manuel Tovar

unread,
Mar 1, 2005, 7:22:00 AM3/1/05
to
Hello,

I have a problem using templates and const.

I want to be sure that in _coefs function, h can not be changed. So I use
const but the result is that I can not use a pointer to double to pass the
array of doubles.

Any idea?

P.D: If you delete the const the code compiles ok.

Thank you in advance.

Jose Manuel Tovar

[C++ Error] Unit1.cpp(39): E2034 Cannot convert 'double *' to 'double[7]'
[C++ Error] Unit1.cpp(39): E2342 Type mismatch in parameter 'h' (wanted
'double ( &) const[7]', got 'double *')


template <class VCTH>
void _coefs (const VCTH& h)
{
}
//---------------------------------------------------------------------------

template <class VCTH>
void _trazador (VCTH& h)
{
h[0] = 2;
_coefs (h);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
double h[7];

h[0] = 1;
_trazador (h);
}
//---------------------------------------------------------------------------

Thomas Maeder [TeamB]

unread,
Mar 1, 2005, 12:26:06 PM3/1/05
to

Please direct your browser at http://info.borland.com/newsgroups/ and read the
newsgroup guidelines. One of them asks us not to post the same question to
different newsgroups, but to pick the most appropriate one and just post
there. Thanks!
0 new messages