0

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.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by flash121
0

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;
     ...
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.