COMPTNG 10A Study Guide - Final Guide: Include Guard, Operator Overloading, Include Directive

47 views3 pages
14 Sep 2017
School
Professor

Document Summary

Define our own custom type through objects and classes. Collection of data members: example: string firstname; int year; (cid:858). (cid:859) = (cid:373)e(cid:373)(cid:271)er a(cid:272)(cid:272)ess operator. Collection of data members accompanied by useful member functions public: data members; member functions; class classname { Classes declaration: e(cid:374)d (cid:271)oth stru(cid:272)ts a(cid:374)d (cid:272)lass defi(cid:374)itio(cid:374)s with (cid:858);(cid:859) data members are also called fields member functions are also called methods when defining member functions of a class, do: classname::funcname. The return type of a member function can be the class itself. *this complex complex::add(complex a) { complex val; return val; A this-pointer of type class_name: points to the object the member function belongs to. Object with no inputs created = default constructor called. When no constructor is explicitly provided, the compiler implicitly defines a trivial default constructor. However, a class with a constructor with inputs will not have a default constructor. When calling the default constructor, no need parentheses.