Monica2003
asked on
Default private access in C++
Hi,
I know that the default access in C++ is private. But why is the default constructor (compiler's constructor if we don't provide one) public?
Example:
class Dog
{
};
void main()
{
Dog fido;
}
If the default access is private, then why am I still able to instantiate an object of the Dog class? Thanks.
I know that the default access in C++ is private. But why is the default constructor (compiler's constructor if we don't provide one) public?
Example:
class Dog
{
};
void main()
{
Dog fido;
}
If the default access is private, then why am I still able to instantiate an object of the Dog class? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
constructor of your own. An implicitly declared default constructor
is public and inline.
That's how C++ comiler generates obj code.
--Niraj