There are a few things missing from your code:
- Have you forgotten the parentheses after
do_something
?
- Also, are you missing a function somewhere? You can't put a
switch
statement directly in the class.
- You can't declare variables directly in the
switch
statement. You need an extra set of braces for that.
class menu {
public:
void do_switch(int a) { // Note function
switch(a) {
case 1:
{ // You need an extra set of braces if you intend to declare variables
tej t;
t.do_something(); // <-- N.B. Parentheses!
}
break;
}
} // Note extra brace to close function
};
class tej:public menu {
public:
void do_something() {
// body of function
}
};
I highly recommend that you pick up a good introductory C++ book, as the things you're getting wrong are quite fundamental to the language. It's less frustrating that way.