Compiler not recognising constructor?

Hi

I'm just finishing up an exercise and creating an object in the interface. My head is probably rather muddled but I'm baffled as to why the compiler is not recognising times as a valid input

(
no instance of constructor matches the argument list
).

times has been successfully used in other objects in same file so I don't think it's an issue with input itself.

May I please tickle your brains on what you think? Truncated code below.

Main
1
2
3
4
5
6
7
8
9
10
11
12
/* ... */
MJArray times(NumberOfDates);
	
	for (unsigned long i=0; i<NumberOfDates; i++)
		times[i] = (i+1)*Expiry/NumberOfDates;
/* ... */
PathDependentBarrier barrierOption(
			times, // <== times doesn't match the argument list??
			callPayOff,
			PathDependentBarrier::call,
			Barrier,
			Rebate);


PathDependentBarrier.h
1
2
3
4
5
6
7
8
9
10
11
12
/* ... */
class PathDependentBarrier : public PathDependent
{
public:
	enum OptionType {call, put};
	PathDependentBarrier(
		const MJArray& LookAtTimes_,
		PayOffBridge& ThePayOff_,
		OptionType TheOptionType_,
		double Barrier_,
		double Rebate);
/* ... */
could you please give some more info about times and barrierOption etc... definitions and declaration etc..
sure, please let me know if you are looking for anything specific

times is an object of class MJArray. MJArray is a class that's based on the STL <valarray>. Its purpose is to store the reset times for when barrier events are tested. Hence it is an argument to barrierOption.

Declaration and definition for MJArray below (although times is confirmed to work in other objects which are a child of base class PathDependent).

Header
1
2
3
4
5
6
7
/* ... */
class MJArray
{
public:
	explicit MJArray(unsigned long size=0);
	MJArray(const MJArray& original);
/* ... */


Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
MJArray::MJArray(unsigned long size)
{
	Size = size;
	Capacity = size;

	if (Size>0)
	{
		ValuesPtr = new double[size];
		EndPtr = ValuesPtr;
		EndPtr += size;
	}
	else
	{
		ValuesPtr = 0;
		EndPtr = 0;
	}
}

MJArray::MJArray(const MJArray& original)
{
	Size = original.Size;
	Capacity = original.Size;

	if (Size>0)
	{
		ValuesPtr = new double[Size];
		EndPtr = ValuesPtr;
		EndPtr += Size;

		std::copy(original.ValuesPtr, original.EndPtr, ValuesPtr);
	}
	else
	{
		ValuesPtr = EndPtr =0;
	}
}


barrierOption is an object of class PathDependentBarrier. Its constructor is written to take the following arguments:
- an MJArray object (by reference)
- PayOff object (by reference)
- OptionType argument (enumerated within class PathDependentBarrier)
- and 2 x double arguments


the definition for PathDependentBarrier constructor (declaration as above) is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PathDependentBarrier::PathDependentBarrier(
	const MJArray& LookAtTimes_,
	PayOffBridge& ThePayOff_,
	OptionType TheOptionType_,
	double Barrier_,
	double Rebate_)
	:	PathDependent(LookAtTimes_),
		ThePayOff(ThePayOff_),
		TheOptionType(TheOptionType_),
		Barrier(Barrier_),
		Rebate(Rebate_),
		NumberOfTimes(LookAtTimes_.size())
{
	
}


are you sure time is generating the error? not one of the other arguments?
yea and that's the funny thing, only time has the error. all other arguments are considered to be expected by the compiler.

although since you asked, I tried to compile it anyway and realised I've left out a const on PayOffBridge. it's probably a bug in Intellisense that pointed it to time but that fixed it, thanks!

it just points to the start of the argument list... it doesn't know wich argument is wrong.
Last edited on
Topic archived. No new replies allowed.