I have an Abstract base class Abc along with two other classes that im trying to get working, but im having trouble declaring the object. I want to declare Abc as a pointer with the coordinates (4,3) , then use it as a circle and find its area. Im getting this error:
I:\C++\AbstractBaseClass_Shapes\main.cpp||In function 'int main()':|
I:\C++\AbstractBaseClass_Shapes\main.cpp|7|error: initializer expression list treated as compound expression|
I:\C++\AbstractBaseClass_Shapes\main.cpp|7|warning: left-hand operand of comma has no effect|
I:\C++\AbstractBaseClass_Shapes\main.cpp|7|error: invalid conversion from 'int' to 'Abc*'|
||=== Build finished: 2 errors, 1 warnings ===|
main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include "Abc.h"
usingnamespace std;
int main()
{
Abc * Obj(4,3);
//Abc * Obj(4,3); doesnt work, how to do this?
Obj = new Circle(5.0); //allocate new circle object
std::cout << "The area of the circle: " << Obj->Area() << std::endl;
delete Obj;
}