Hello,

I have a class called personalAccount (which is a derived class from another class, but i dont think this will matter in this case), which should have a static array of chars, but i keep getting an error int my current default constructor and i cant seem to find the reason.

The code:

class header file

class personalAccount : public limit
{
         protected:
               char* array;
               static int size;
         public:
               personalAccount();
               personalAccount(string name,double status,double limit1):limit(name,status,limit1){}
               ~personalAccount(){}
};

..and cpp file

int personalAccount::size=100;
//default constructor
personalAccount::personalAccount()
{
               array=new char[size]; //this is the line where the error is supposed to be
               for(int i=0; i<size; i++)
                       array[i]='x';
}

The error i keep getting is: 'personalAccount::personalAccount(const personalAccount&)': cannot convert parameter 1 from int to const personalAccount&,

reason: cannot convert from 'int' to 'const personalAccount'
No constructor could take the source type, or constructor overload resolution was ambiguous.

Any advice would be much appriciated.

Recommended Answers

All 2 Replies

I suppose you are using the personalAccount somewhere, could you post that code, i.e.
if you have e.g. something like

int main()
{
    personalAccount Account;
     ...

Won't be neccessary, i checked my main function and realized i was using the wrong constructor when i was initilazing an object. Thanks for pointing me in the right direction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.