Calling base function from derived overloaded function

Here is a sample of my question

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Base{
     public:
          int getNum();
     private:
          int numToGet;
}

class Derived: public Base {
     public:
          friend ostream& operator<<(ostream& output, const Derived &B);
}

ostream& operator<<(ostream& output, const Derived &B) {
     // I would like to call getNum from the base class,
     // but using B.getNum() was returning
     // "passing 'const Derived' as 'this' argument of int Base::getNum()'
     // discards qualifiers

int main()
Derived B;
cout << B;




Any help would be appreciated.
Last edited on
Sorry, i forgot to change my getNum function to a constant function.
Works now.
Topic archived. No new replies allowed.