I'm having lots of trouble getting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
int main()
{
attribute *aPtr, *bPtr;
aPtr = new size;
aPtr->is = 1;
bPtr = new shape;
bPtr->is = 3;
hypothesis kPoth(aPtr, bPtr);
block aBlock(true, 1, 2, 1);
if(aBlock.szAttOne == *(kPoth.first)) std::cout << "Works" << std::endl;
return 0;
}
|
to work properly. I keep getting an error where gcc won't recognize my type as anthing but the attribute base class, but I would love for the type of the pointed object to be used instead.
HALP11!1!
heres the error messages
attblockimp.cpp: In function ‘int main()’:
attblockimp.cpp:231:38: error: no match for ‘operator==’ in ‘aBlock.block::szAttOne == * kPoth.hypothesis::first’
attblockimp.cpp:231:38: note: candidates are:
attblockimp.cpp:14:6: note: virtual bool size::operator==(size)
attblockimp.cpp:14:6: note: no known conversion for argument 1 from ‘attribute’ to ‘size’
attblockimp.cpp:24:6: note: virtual bool size::operator==(color)
attblockimp.cpp:24:6: note: no known conversion for argument 1 from ‘attribute’ to ‘color’
attblockimp.cpp:19:6: note: virtual bool size::operator==(shape)
attblockimp.cpp:19:6: note: no known conversion for argument 1 from ‘attribute’ to ‘shape’
The classes are written such that aBlock's szAttOne member is a size type while kPoth's first member is an attribute pointer. There are overloaded operators for each class size, shape, and color are derived from attribute. Attribute is an abstract base class. The second error message shows the most relevant information for my question because it is trying to resolve this as (size == attribute) which isn't an overloaded operator functionm while I want it to recognize the object pointed to by the attribute pointer, which is a size type variable.