devwiki:quickdevref

Quick Dev Ref page is for quick syntax reference.

Editor Reference

IDE - big Xcode, Visual Studio Community edition (replaced VS Express), eclipse, NetBean
IDE - small
cross-platform
small
sort based by
my experience
* Qt Creator
* CodeLite IDE
* Bloodshed Dev-C++ (old) (SF new)
* Code Blocks (SF link)
* Ultimate++
code editor
without compiler
vi, vim, Notepad++, sublime text, Atom, VisualStudio Code
others WebStorm-JS IDE, IntelliJ IDEA - Java, Web
library Boost, Qt, ref: link
Blogs PHP & Linux, Android

Procedural type language vs Object-oriented type language

Process-oriented Difference:

  • structure definition and operational functions
  • like Action + Subject
  • class definition and behavior methods
  • like Object + Action

Object-oriented characteristics

  • Encapsulation
  • include properties and methods inside itself
  • Inheritance
  • Polymorphism

Developing Process

Language Structure

  • Syntax - Grammar
  • Data type
    • data type conversion + user defined
  • Logic operation
  • Constructor
  • statement
    • declaration statement : define variables
      • type name
      • object name
      • function name
    • expression statement : to assign value
    • iteration statement : like a loop
    • conditional statement : also known as selection statement
    • exception statement : error handling

C++ / cpp

One definition rule : any object can only have one definition.
A variable in C++ is a name for a piece of memory that can be used to store information.

// defining
class ClassName {
	int a;
	public:
		int b;
		int funcA (){ ... }		
};
 
// function
int main(){
	ClassName objA;
	objA.funcA();		// do method
 
	cout << " text here \n";
 
	return 0;
}

Data type: bool, char, int, float, double, long double, void, enum
Data structure: pointer, array, reference, structure, class
Scope and Namespace: external, internal, none
Access right: public, private, protected
Constant:

const int a=0; //constant can not be changed

Operation: static cast, dynamic cast, implicit, explicit
Logic operation: ==, <, >, ++, switch(n){case a: act1;break;}, break, continue, return, goto
Iteration:

for ( initial; condition; increment ) { statement }
while ( condition ) { statement }
do{ statement }  while ( condition )

Exception:

try{statement; on error, throw variable;} catch(variable){statement;}

Function (support overloading, virtual): void func1 (int x, int y){}
Class:

Objective-C / objc m

[movie setTitle:@“Iron man”]; = movie.title = @“Iron man”;
[movie title]; = movie.title;

Java

IO stream

System.out.println("Hello!");
x = System.in.read();

Data type: int, short, int, long, float, double, byte, char, string
Data structure: array Logic operation: ==, !==. <, >, ⇐, >=, &&, || , !
Condition statement:

  • if(){}
  • if(){} else{}
  • if(){} else if(){} else{}
  • switch(n){case “val1”: stt; break;}

Iteration:

  • white(condition){}
  • do {} while (condition);
  • for (int i=0; i < 10; i++){ }

SQL

DELETE FROM `databaseName`.`tableName` WHERE `databaseName`.`tableName` = 'theValue'

Language concepts

the variable of data type like (int char byte short) is in stack memory; only passed by value;

the variable of other class objects like (Array ClassName) is in heap memory, and address is in stack memory.

  • data [ public , private ] ⇐⇒ variable ⇐⇒ member
  • function [ public , private ]
  • method [ public , private ]

Class can be defined inside another class; nested.

In Class, there is some key feature that never change, like Class Chinese, a property “nationality” is always “chinese”;

So, this kind of property in class never changes in new instances, same as property, method also can be static as that;

Because of “static” nature, the property and method is pre-built and can not have individual value for each instance, therefore, even there is no instance of a class, the property and method can be directly used even without any instance created.

Its nature:

  • all instance shares one copy of the same static property
  • Drawback, static method or variable can only access static method and variable; Because non-static stuffs are not there before a instance is created, and key word “this” also can not by used by static stuffs
  • However, static method and variable can be accessed by anyone

Why there is a “return” value

Simulate real-world procedural, like “Go and buy a bag of super”;

You as main function (home director), The person is a function, and that person once being called, he will return you a bag of super.

if that person made a mistake, then he may return a bag of salt.

so return can be any possible value.

  • devwiki/quickdevref.txt
  • Last modified: 2021/08/28 07:52
  • by ying