Can someone help me with this C++ Inheritance problem?
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
class Printer {
protected:
int level;
public:
int getlevel();
};
int Printer::getlevel() {
return level;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Why doesn't that work?
Can someone help me with this C++ Inheritance problem?c++ compiler
You can't put member function definitions from nested classes outside the class declaration, at least not with Dev-C++. I'm not sure if any compiler would support that. If you defined the getlevel function right after the declaration it would work:
class Printer {
...
int getlevel() { return level; }
...
};
...
Can someone help me with this C++ Inheritance problem?c++ cli
You should use that protected varible within class and subclass of that class. then only it works.
public: within that class and outside of the class
protected:within that class and subclasses of that class
private:within that class only and cannot be accessed anywhere except within the class.
More Related Questions and Answers ...
The information post by website user , we not guarantee correctness.
Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes
