`
wihoho
  • 浏览: 8805 次
  • 性别: Icon_minigender_1
  • 来自: Singapore
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表
3 primary features of OOP Encapsulation Inheritance Polymorphism
class A user-defined datatype which groups together related pieces of information Instance An instance is an occurrence of a class class student{ public: char *name; int studentID; }; int main(){ student s1; student s2; }   Constructor Method that is calle whien ...
&x evaluates to the adress of x in memory. *(&x) evaluates to the someting as x.   Pointer advantages: More flexible pass-by-reference Manipulate comlex data structure efficiently Use polymorphism Pointers are variables stroring memory address.   Declaring pointers:  int *ptr = &a ...
Array   fixed number of elements of the same type stored sequentially in memory initialization, or unexpected results arrays are passed by reference multidimensional arrays are merely an abstraction for programmers, as all the elements in the array are sequential in memory   String   simp ...
Why define your own functions? Readability Maintainability Code reuse #include <iostream> using namespace std; int raiseToPower(int base, int exponent) { int result = 1; for (int i = 0; i < exponent; i = i + 1) { result = result * base; } return result; } int main( ...
Control structure conditionals if switch loops while do...while for nested control structures 这些都跟java是一致的,谁叫java是从C++改过来的呢?
1.1 Why use a language like C++   Conciseness Maintainability Portability 1.2 The compilation process          sorce file>>>Prcessed code>>>Object file   1.3 General notes on C++                case sensitive 2.1 hello world /* * File: main.cpp * Author: Gong ...
  class Node<E>{ E item; Node prev, next; Node(E newItem){ item = newItem; prev = next =null; } } class CircularDoublyLinkedList{ private Node head; private Node tail; private int size; CircularDoublyLinkedList(){ ...
Let us consider the below traversals: Inorder sequence: D B E A F CPreorder sequence: A B D E C F In a Preorder sequence, leftmost element is the root of the tree. So we know ‘A’ is root for given sequences. By searching ‘A’ in Inorder sequence, we can find out all elements on left side of ...
Use recursion and traversal to solve. boolean BSTbranch(TreeNode start, TreeNode end){ if(start == end) return true; if(start != null){ if(!BSTbranch(start.left, end){ if(!BSTbranch(start.right, end) return false; else return true; ...
Global site tag (gtag.js) - Google Analytics