Reputation: 167
I've seen a few answers on this topic, but to my knowledge they don't quite answer the problem I'm getting. Here is my paraphrased code:
using namespace std;
class classname
{
private:
int foo;
classname();
};
classname::classname()
{
//dostuff
}
int main(){
classname arr[5];
}
The code errors:
error: ‘classname::classname()’ is private within this context
My best guess is that private:
bled into my constructor definition. How do I stop this?
Upvotes: 1
Views: 3107
Reputation: 131
Everything after private:
is marked as private until the end of the class is reached or another visibility token. Put your function above the private:
or put a public:
before the function declaration.
Upvotes: 1