C++: compile errors :(

UlricT

Golden Member
Jul 21, 2002
1,966
0
0
hey guys,
this problem cropped up as I was working on an assignment. I have been sitting on this for some time, and I hope you guys can help out. Got a lot further to go, and i'm stuck at nearly the beginning.


error: request for member `clone' in `tright->TimeValue::scale(float)(dleft)', which is of non-aggregate type `Value*'

return tright ->scale(dleft).clone() is the calling function.

now, dleft is simply an int, and tright is a TimeValue*. Value is the base class for TimeValue, and TimeValue has both scale() and clone() defined in itself.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
A Value* is a non-aggregate type; it is a pointer. You're trying to access a member of the pointer itself, which doesn't make any sense. I assume you want to access the clone() method of the Value that it points to. I.e.:

return tright ->scale(dleft)->clone()
 

UlricT

Golden Member
Jul 21, 2002
1,966
0
0
hmm... thats what I thought, but the problem is the calling function is something the instructor has told us not to touch. and clone() has to have a value* as its return type, as the base class (which again cannot be modified) has a virtual instance of clone() with a return type of value* :(

I hope that made some sense, and thanks for the sugeestion BingBong :)
 

juiio

Golden Member
Feb 28, 2000
1,433
4
81
Originally posted by: UlricT

return tright ->scale(dleft).clone() is the calling function.

now, dleft is simply an int, and tright is a TimeValue*. Value is the base class for TimeValue, and TimeValue has both scale() and clone() defined in itself.

What does scale() return? Whatever it returns is what needs to have a member function named clone(). What you wrote is the same as this:

blah = tright->scale(dleft);
return blah.clone();

However your explanation made it sound like clone() was in tright's class rather than blah's class.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
make scale() return a reference rather than a pointer, if the problem is using the "." to call clone().
 

UlricT

Golden Member
Jul 21, 2002
1,966
0
0
arrggghhhhh!!!!! this stuff is killing me! I just modified the code so that clone IS referred to through a pointer. Now THIS happens, and I have NO idea as to what is going on...
Undefined first referenced
symbol in file
TimeValue::TimeValue[in-charge]() timenode.o

I have to use the provided makefile in g++, so please help me guys

 

UlricT

Golden Member
Jul 21, 2002
1,966
0
0
thanks for that suggestion Oog! That fixed the earlier problem and I really appreciate it :)

Now I am still getting the error I mentioned above, and I don't know where to go.
 

UlricT

Golden Member
Jul 21, 2002
1,966
0
0
fixed :D... it was my default constructor there :) thx for all the help guys!