Reputation: 4251
I defined ball
structure in this way:
struct ball
{
_vector coordinates;
_vector velocity;
_vector acceleration;
int border;
int color;
int radius;
float mass;
void step();
void clear();
void render();
};
(data type _vector
is defined before and it represents the vector in mathematics)
in the main function i wanted to define an array of ball
s so i wrote this code:
int main(int argc, char** argv)
{
struct ball balls[NO_BALLS];
.
.
.
}
but when i wanna compile the code i get this error:
no matching function for call to `ball::ball()' candidates are: ball::ball(const ball&)
Upvotes: 0
Views: 111
Reputation: 110658
If you define the copy constructor ball::ball(const ball&)
(which you've actually commented out in your code), there will be no compiler generated defaulted default constructor. There needs to be a default constructor for your array definition to work (because it default initializes each of the elements). So simply provide a default constructor: ball:ball() { }
. You will probably want to initialize your member variables in this constructor.
Upvotes: 9