473,396 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

operator new does not accept 3 arguments !?

DGStr* pS = new DGStr[3];

// gives error:
error C2660: 'operator new': function does not accept 3 arguments
see 'void GLBASIC::DIM<GLBASIC::DGStr>
(GLBASIC::DGArray<T>&,DGInt,DGInt,DGInt,DGInt,DGIn t,DGInt,DGInt,DGInt)'
with
[
T=GLBASIC::DGStr
]
// Here's my DGStr declaration
class DGStr
{
public:
DGStr();
DGStr(CGStr a);
DGStr(const DGStr& a);
DGStr(const char* c);
DGStr(int a);
DGStr(float a);
DGStr(double a);
~DGStr();

const char* c_str();

DGStr& operator=(const DGStr& a);
DGStr& operator=(int a);
DGStr& operator=(float a);
DGStr& operator=(double a);
DGStr& operator=(const char* a);
operator DGInt()const;

DGStr& operator+=(const char* a);

// DGStr operator +-*/ (const DGStr& a);
#define MK_OPERATOR_CL(zz) \
DGStr& operator zz(const DGStr& a); \
DGStr& operator zz(int a); \
DGStr& operator zz(float a); \
DGStr& operator zz(double a);
MK_OPERATOR_CL(+=)
MK_OPERATOR_CL(-=)
MK_OPERATOR_CL(*=)
MK_OPERATOR_CL(/=)
MK_OPERATOR_CL(^=)
#undef MK_OPERATOR_CL
};
what can it be!?

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}
Nov 28 '05 #1
6 4578

template <class T>
void DIM(DGArray<T>& arr,
DGInt xt1=0, DGInt xt2=0, DGInt xt3=0, DGInt xt4=0,
DGInt xt5=0, DGInt xt6=0, DGInt xt7=0, DGInt xt8=0)
{
int* pI = new int[5]; // here the same error !?
}

need declaration of DGArray ??
Nov 28 '05 #2

"Gernot Frisch" <Me@Privacy.net> schrieb im Newsbeitrag
news:3v*************@individual.net...

template <class T>
void DIM(DGArray<T>& arr,
DGInt xt1=0, DGInt xt2=0, DGInt xt3=0, DGInt xt4=0,
DGInt xt5=0, DGInt xt6=0, DGInt xt7=0, DGInt xt8=0)
{
int* pI = new int[5]; // here the same error !?
}

need declaration of DGArray ??


Yuck!! No error with GCC 2.95 - I'm totally lost now. I must be able
to compile using VC7.1, please, please help :((
Nov 28 '05 #3
* Gernot Frisch:

"Gernot Frisch" <Me@Privacy.net> schrieb im Newsbeitrag
news:3v*************@individual.net...

template <class T>
void DIM(DGArray<T>& arr,
DGInt xt1=0, DGInt xt2=0, DGInt xt3=0, DGInt xt4=0,
DGInt xt5=0, DGInt xt6=0, DGInt xt7=0, DGInt xt8=0)
{
int* pI = new int[5]; // here the same error !?
}

need declaration of DGArray ??


Yuck!! No error with GCC 2.95 - I'm totally lost now. I must be able
to compile using VC7.1, please, please help :((


Seemingly you haven't presented the code actually responsible for the
error you described in your first posting, a new[] call producing "The
function is called with an incorrect number of parameters."

Try to reproduce the problem in a simplest, smallest possible program.

As a plan of attack, move your DGStr class to a small test program.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 28 '05 #4
JE

Gernot Frisch wrote:
"Gernot Frisch" <Me@Privacy.net> schrieb im Newsbeitrag
news:3v*************@individual.net...

template <class T>
void DIM(DGArray<T>& arr,
DGInt xt1=0, DGInt xt2=0, DGInt xt3=0, DGInt xt4=0,
DGInt xt5=0, DGInt xt6=0, DGInt xt7=0, DGInt xt8=0)
{
int* pI = new int[5]; // here the same error !?
}

need declaration of DGArray ??


Yuck!! No error with GCC 2.95 - I'm totally lost now. I must be able
to compile using VC7.1, please, please help :((


You might want to check your compiler settings (e.g. if you've got /GX,
/EHa, or /EHs).

Nov 28 '05 #5

Gernot Frisch wrote:
DGStr* pS = new DGStr[3];

// gives error:
error C2660: 'operator new': function does not accept 3 arguments
see 'void GLBASIC::DIM<GLBASIC::DGStr>
(GLBASIC::DGArray<T>&,DGInt,DGInt,DGInt,DGInt,DGIn t,DGInt,DGInt,DGInt)'
with
[
T=GLBASIC::DGStr
]


Are you sure you're not mixing debug code with release code.
It's common to have implementation in which the debug version of new
takes three arguments.
Example:
inline void * operator new(size_t bytes, const char *source_file, int
line_no);
inline void * operator new[](size_t bytes, const char *source_file, int
line_no);

Usually there's a macro to resolve this in debug mode.
#define _leaktracker61_NEW new(__FILE__, __LINE__,
__FUNCTION__)
#define new _leaktracker61_NEW

If something is wrong with referencing your macro, or if some how
you're mixing release code with debug code, that can lead to getting a
compile error as the one you described.
For more info, see following link:
http://code.axter.com/leaktracker.h

Nov 28 '05 #6

"Axter" <go****@axter.com> schrieb im Newsbeitrag
news:11*********************@g43g2000cwa.googlegro ups.com...

Gernot Frisch wrote:
DGStr* pS = new DGStr[3];

// gives error:
error C2660: 'operator new': function does not accept 3 arguments
see 'void GLBASIC::DIM<GLBASIC::DGStr>

(GLBASIC::DGArray<T>&,DGInt,DGInt,DGInt,DGInt,DGIn t,DGInt,DGInt,DGInt)'
with
[
T=GLBASIC::DGStr
]


Are you sure you're not mixing debug code with release code.
It's common to have implementation in which the debug version of
new
takes three arguments.
Example:
inline void * operator new(size_t bytes, const char *source_file,
int
line_no);
inline void * operator new[](size_t bytes, const char *source_file,
int
line_no);

Usually there's a macro to resolve this in debug mode.
#define _leaktracker61_NEW new(__FILE__, __LINE__,
__FUNCTION__)
#define new _leaktracker61_NEW

If something is wrong with referencing your macro, or if some how
you're mixing release code with debug code, that can lead to getting
a
compile error as the one you described.
For more info, see following link:
http://code.axter.com/leaktracker.h


Yes! Bingo! that was it! Thank you

Nov 29 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: bsaucer | last post by:
I am creating a class with operator overloads. It makes references to another class I've created, but do not wish to modify. I try to overload an operator having arguments having the other class...
2
by: Julian | last post by:
I would like to have output from my program to be written to cout as well as a file. (actually, i want several other output options but this should explain my problem in the simplest way). I have...
3
by: Sensei | last post by:
Hi. I have a problem with a C++ code I can't resolve, or better, I can't see what the problem should be! Here's an excerpt of the incriminated code: === bspalgo.cpp // THAT'S THE BAD...
8
by: Floogle | last post by:
how do i create a virtual == operator. I've tried the following but it's incorrect... class Interface { ... public: virtual bool operator==(const Interface& rhs)const=0;
2
by: PengYu.UT | last post by:
I'm wondering whether the operator can accept more than 1 arguments Suppose I have a object which is essentially a 2 dimensional array, I want to use operator to access the data. I don't what...
19
by: jacob navia | last post by:
C++ introduced an interesting feature (among others): operator overloading. The idea is to build a mechanism for the user defining its own number types and the operations to be done with them. ...
30
by: none | last post by:
I'm trying to overload the = operator using templates, but I have some problems with one of the overloads, I would like to make something like that: intvariable = fooclass; here's a pseudo...
3
by: Thomas Lenz | last post by:
The code below should allow to use a comma instead of << with ostreams and include a space between two operands when comma is used. e.g. cout << "hello", "world", endl; should print the line...
19
by: C++Liliput | last post by:
I have a custom String class that contains an embedded char* member. The copy constructor, assignment operator etc. are all correctly defined. I need to create a map of my string (say a class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.