Object Oriented Programming in C++ - suggestions for exercises

Aug 19, 2018 at 12:15pm
Hi I am a beginner level c++ programmer and I am trying to learn object oriented programming. I'm quite good with procedural programming(loops, conditionals, switch statements) and I've coded some factorization algorithms as well as a program to grade exam papers (you bung the students test results in and it gives A*/A/B etc.)

I'm now trying to learn about classes and I've made a simple searchable database. Can anyone suggest simple programs to help me learn about how to use classes? (I don't understand constructors and member functions, so would appreciate some help with these concepts.) Thanks.
Aug 19, 2018 at 12:21pm
Learning OOP consists of 2 different parts.
First you need to learn the C++ rules and syntax about classes.
Second you need to learn the concepts about OOP like inheritance, encapsulation....
There are tons of tutorials about this. Just Google "OOP C++" without quotes
Aug 19, 2018 at 12:42pm
I'm currently reading C++ for Dummies and I've read cplusplus.com's documentation. I understand the concepts in theory but I don't understand how to "get my teeth" into classes. Can somebody take me through how to make a default constructor and suggest simple exercises to help me learn how to use them?
Aug 19, 2018 at 1:36pm
Making a default constructor:

1
2
3
4
5
6
7
8
9
10
11
12
13
class location
{
  public:
    int x;
    int y;

  location()  // this is the default constructor. Think of it as a function that gets called when you default make one of these objects
  {
    x = 4;
    y = 7;
  }

};


Anything not clear?
Last edited on Aug 19, 2018 at 1:36pm
Aug 19, 2018 at 5:15pm
closed account (E0p9LyTq)
I understand the concepts in theory but I don't understand how to "get my teeth" into classes.

http://www.learncpp.com/cpp-tutorial/81-welcome-to-object-oriented-programming/
Topic archived. No new replies allowed.