Array of Objects Error

Discussion in 'C++' started by Hawkpath, Sep 10, 2010.

  1. Hawkpath

    Hawkpath New Member

    Joined:
    Sep 10, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello, I made a class and now I want to store instances of those classes in an array. I looked it up and found it was as easy as:
    className arrayName[x]When I tried that I got this error:
    error: no matching function for call to 'archerTower::archerTower()'|

    My class:
    Code:
     // class
    class archerTower{
        float cX;
        float cY;
        float radius;
        public:
            archerTower(float,float,float);
            float getcX(){return cX;}
            float getcY(){return cY;}
            float getRadius(){return radius;}
    };
    
    //constructor
    archerTower::archerTower(float x, float y, float r)
    {
        cX = x;
        cY = y;
        radius = r;
    }
    And finally when I try to create the array:
    archerTower archerTowerArray[4];Can anyone please help me?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice