oop is mostly a naming convention. the program gets structured differently, but the control flow is pretty much identical. some people hate it for that reason and i think that is valid, most of the complaints are pretty stupid.
#include <iostream>
struct S {
int v_;
S(const int& val) : v_(val) { }
};
int add(S* s, const int& val)
{
return s->v_ + val;
}
class C {
private:
int v_; /// note this is private
public:
C(const int& val) : v_(val) { }
int add(const int& val) const;
};
int C::add(const int& val) const
{
return v_ + val;
}
int main()
{
S s(10);
C c(10);
std::cout << add(&s, 20) << "\n" << c.add(20) << "\n";
return 0;
}