🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.oodesign
Article #41

const and Templates

#41
From: Jose Manuel Tovar
Date: Tue, 01 Mar 2005 12:22
43 lines
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);
}
//---------------------------------------------------------------------------
Technical Details
Message-ID: <42245e68@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,dd0b17cceb5df690,start
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Jose Manuel Tovar" <jtovar@hrs-spiratube.com>
Newsgroups: borland.public.cppbuilder.oodesign
Subject: const and Templates
Date: Tue, 1 Mar 2005 13:22:00 +0100
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 80.33.76.158
Message-ID: <42245e68@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1109679720 80.33.76.158 (1 Mar 2005 04:22:00 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail