• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++: compile errors :(

UlricT

Golden Member
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.
 
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()
 
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 🙂
 
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.
 
make scale() return a reference rather than a pointer, if the problem is using the "." to call clone().
 
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

 
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.
 
Back
Top