I am attempting to make a class called Profile and have numerous profiles in an array (70 to be exact).


Class Profile {
  int _age;
  string _fname;
  string _lname;
  int _height;
  char _gender;

  Profile(int val, char gender) : _age(val), _gender(gender) {  }

  int getHeight();

  int getAge();

int Profile::getHeight() {
    return _height;

int Profile::getAge() {
     return _age;

#include "Profile.h"

int main() {

Profile myarray[70];
return 0;


The error is that in Profile.h, no matching function to call Profile:: Profile()

Edited 6 Years Ago by Blitze: n/a

C++ attempts to call the default constructor for each element of an array. Profile doesn't have a default constructor (only one that takes two arguments). Either provide that default constructor or make myarray hold pointers to Profile instances.

C++ will provide a default constructor for a class only if you don't provide one of your own.

Edited 6 Years Ago by griswolf: mention why

Ok, i have made it use pointers and it works beautifully. I have a file with all of the profiles filled out and I thought that would allow it to call it for the array obviously it did not.

Thank you very much for your time!

Edited 6 Years Ago by Blitze: n/a

This question has already been answered. Start a new discussion instead.