Can someone help me with this C++ Inheritance problem?

 Dont Buy Textbooks. Rent 'EM Save 60-80%



#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 ...
  • Urgent please C++ !(1) inheritance syntax?
  • Inheritance in C sharp?
  • Why java will not support multiple inheritanc..
  • Merits and demeritsof private inheritance in ..
  • Inheritance with C++ (type casting)?
  • What is Inheritance in C++ language?
  • Error in Private Inheritance in C++..PLEASE t..
  • Would u pls explain Inheritance in C#?
  • What r the diff Types of Inheritance in C#?
  • What are the advantages and disadvantages of ..
  • Can somebody give me an example on polymorphi..
  • Is there an inheritance for angelica c metzga..
  • Can Anyone explain in detail the inheritance(..
  • I want a simple c++ program on hierarchical i..
  • Wrte a c++ pgm using hierarchical inheritance..
  • Can u please help writting a c++ pgm for mult..
  • What is inheritance? Define Public and Privat..
  • Write a c++ pgm to demonstrate multilevel inh..
  • I need expert advice to create a barcode syst..

  • The information post by website user , we not guarantee correctness.

    

    Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes