I have created these classes and used code::block to compile them but there is a "undefined reference Rectangle::setWid()" "undefined reference Rectangle::setLen()"...
Please help.
Here is my codes:
You have no implementation for Rectangle::getArea(). That would you would get an undefined reference for it. I don't see offhand why you would be getting an undefined reference for getLen() or getWid().
I'm presuming the nested main functions is a cut and paste error.
1 2 3 4 5
int main()
{
Rectangle l;
int main()
{
PLEASE USE CODE TAGS (the <> formatting button) when posting code. http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
@DTSCODE - the compiler will do a type conversion from an int to a double. Specifying an int won't cause an undefined reference.
Edit: You could be getting the undefined external because you did not include rectangle.cpp in your project, therefore it did not get compiled nor linked into your executable.
I compiled this with VS2010 and did not get undefined externals for either getWid() or getLen(). I did receive an undefined external for getArea() as noted above.