repl.it
C++

C++ solo learn classes

fork
loading
Files
  • main.cpp
  • Birthday.cpp
  • Birthday.h
  • Daughter.cpp
  • Daughter.h
  • Mother.cpp
  • Mother.h
  • Person.cpp
  • Person.h
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include "Person.h"
#include "Daughter.h"

int main() {
  Person person;
  person.PrintRandom();
  std::cout << std::endl;
  const Person personTwo;
  // this is a constant object, with contant object you can not call normal methods, you can only call methods who are also declared as cosntant, also you can not change any member values via constant object, so once you declare a object constant the attributes like int, float, etc that you want to change are not going to be mutable,
  // personTwo.SetName(); <<<<<<---- error, can not call non-const method from const oject

  Person personGirl(true);

  Person PersonWithBirthday(5, Birthday(8, 20, 2003));

  Daughter daughter;
  daughter.InheritingClassRunThis();
}
Fetching token
?