delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/24/06:16:51

From: "walter.koebler" <walter DOT koebler AT franken2000 DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: How to invoke own new[]-operator?
Date: Wed, 22 Oct 1997 18:49:29 +0100
Organization: Nacamar Data Communications
Lines: 15
Message-ID: <62lalj$ng1$1@news.nacamar.de>
NNTP-Posting-Host: 195.63.7.66
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Own Operator:
template<class X, class V>
inline void* operator new[](size_t t, int anz, const V& v)
{ X* x = RAM.assign_ram(t,anz);
// equivalent to :X* x = (X*) calloc(anz,t);
  for(int i=0;i<anz;i++) new (x+i) X(v);
  return x;
}
Small test-application:
void main(void){ int* i = new int [10] (int(12345));}
How can I use my new[]-operator instead of the build-in one?
All other own new-operators work but not the overloaded
subscription. Program runs with GNU C++.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019