// { dg-do assemble }
|
// { dg-do assemble }
|
// GROUPS passed visibility
|
// GROUPS passed visibility
|
// visibility file
|
// visibility file
|
// From: Sandeep Shroff
|
// From: Sandeep Shroff
|
// Date: Thu, 05 Aug 1993 17:23:20 -0700
|
// Date: Thu, 05 Aug 1993 17:23:20 -0700
|
// Subject: Access to private constructor.
|
// Subject: Access to private constructor.
|
// Message-ID: <9308060023.AA10283@neptune.caere.com>
|
// Message-ID: <9308060023.AA10283@neptune.caere.com>
|
#include
|
#include
|
#include
|
#include
|
|
|
class Base
|
class Base
|
{
|
{
|
public:
|
public:
|
char* getName() {return name_;}
|
char* getName() {return name_;}
|
|
|
private:
|
private:
|
Base();
|
Base();
|
Base(char* str);
|
Base(char* str);
|
|
|
char* name_;
|
char* name_;
|
};
|
};
|
|
|
class Derived : public Base
|
class Derived : public Base
|
{
|
{
|
public:
|
public:
|
Derived(int n, char* str);
|
Derived(int n, char* str);
|
Derived(int n);
|
Derived(int n);
|
|
|
int getNum() {return num_;}
|
int getNum() {return num_;}
|
private:
|
private:
|
int num_;
|
int num_;
|
};
|
};
|
|
|
Base::Base() // { dg-error "is private" }
|
Base::Base() // { dg-error "is private" }
|
{
|
{
|
name_ = std::strcpy(new char[std::strlen(" ") + 1], " ");
|
name_ = std::strcpy(new char[std::strlen(" ") + 1], " ");
|
}
|
}
|
|
|
Base::Base(char* str) // { dg-error "is private" }
|
Base::Base(char* str) // { dg-error "is private" }
|
{
|
{
|
if(str != NULL)
|
if(str != NULL)
|
name_ = std::strcpy(new char[std::strlen(str) + 1], str);
|
name_ = std::strcpy(new char[std::strlen(str) + 1], str);
|
}
|
}
|
|
|
Derived::Derived(int n, char* str) : Base(str) // { dg-error "within this context" }
|
Derived::Derived(int n, char* str) : Base(str) // { dg-error "within this context" }
|
{
|
{
|
num_ = n;
|
num_ = n;
|
}
|
}
|
|
|
Derived::Derived(int n) : Base() // { dg-error "within this context" }
|
Derived::Derived(int n) : Base() // { dg-error "within this context" }
|
{
|
{
|
num_ = n;
|
num_ = n;
|
}
|
}
|
|
|
|
|
|
|
int main()
|
int main()
|
{
|
{
|
// Derived* d = new Derived(10, "test");
|
// Derived* d = new Derived(10, "test");
|
Derived* d = new Derived(10);
|
Derived* d = new Derived(10);
|
|
|
std::cerr << d->getNum() << "\t" << d->getName() << std::endl;
|
std::cerr << d->getNum() << "\t" << d->getName() << std::endl;
|
}
|
}
|
|
|
|
|
|
|
|
|