Thread View: borland.public.cppbuilder.oodesign
2 messages
2 total messages
Started by Jose Manuel Tovar
Tue, 01 Mar 2005 12:22
const and Templates
Author: Jose Manuel Tovar
Date: Tue, 01 Mar 2005 12:22
Date: Tue, 01 Mar 2005 12:22
43 lines
1971 bytes
1971 bytes
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);
}
//---------------------------------------------------------------------------
Re: const and Templates
Author: Thomas Maeder [TeamB]
Date: Tue, 01 Mar 2005 17:26
Date: Tue, 01 Mar 2005 17:26
5 lines
1343 bytes
1343 bytes
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!
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads