I tried to learn about the access specifier in c++, So i access a public and protected member from the base class and performed a add function in the derived class as shown below,
#include<iostream>
using namespace std;
class Base
{
public:
int a;
protected:
int b;
};
class Derived : public Base
{
public:
int sum;
void add()
{
a = 10;
b = 20;
sum = a + b;
}
};
int main()
{
Derived Obj;
Obj.add;
cout << "The sum : " << Obj.sum << "\n";
return 0;
}
But while compile i get the following error message "statement cannot resolve address of the overload function" can anyone explain what is the error?
Thanks in advance
The function call is missing parenthesis in the following line:
Obj.add;
It should be: Obj.add();