operator new does not accept 3 arguments !?

G

Gernot Frisch

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,DGInt,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!?
 
G

Gernot Frisch

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 ??
 
G

Gernot Frisch

Gernot Frisch said:
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 :((
 
A

Alf P. Steinbach

* Gernot Frisch:
Gernot Frisch said:
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.
 
J

JE

Gernot said:
Gernot Frisch said:
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).
 
A

Axter

Gernot said:
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,DGInt,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
 
G

Gernot Frisch

Axter said:
Gernot said:
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,DGInt,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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top