Thursday, August 6, 2015

CPP_note

http://www.cplusplus.com/doc/tutorial
1. cin and strings
#include <iostream>
#include <string>
using namespace std;

int main ()
{
  string mystr;
  cout << "What's your name? ";
  getline (cin, mystr);
  cout << "Hello " << mystr << ".\n";
  return 0;
}

2. stringstream
string mystr ("1204");
int myint;
stringstream(mystr) >> myint;

3. passed by reference
#include <iostream>
using namespace std;

void duplicate (int& a, int& b, int& c)
{
  a*=2;
  b*=2;
  c*=2;
}

int main ()
{
  int x=1, y=3, z=7;
  duplicate (x, y, z);
  cout << "x=" << x << ", y=" << y << ", z=" << z;
  return 0;
}
By qualifying them as const, the function is forbidden to modify the values of neither a nor b, but can actually
access their values as references:
string concatenate (const string& a, const string& b)
{
  return a+b;
}

4. function template (are_equal(10,10.0) Is equivalent to: are_equal<int,double>(10,10.0))
#include <iostream>
using namespace std;

template <class T, class U>
bool are_equal (T a, U b)
{
  return (a==b);
}

int main ()
{
  if (are_equal(10,10.0))
    cout << "x and y are equal\n";
  else
    cout << "x and y are not equal\n";
  return 0;
}

5. pointer
#include <iostream>
using namespace std;

int main ()
{
  int firstvalue, secondvalue;
  int * mypointer;

  mypointer = &firstvalue;
  *mypointer = 10;
  mypointer = &secondvalue;
  *mypointer = 20;
  cout << "firstvalue is " << firstvalue << '\n';
  cout << "secondvalue is " << secondvalue << '\n';
  return 0;
}

The arrow operator (->) is a dereference operator that is used exclusively with pointers to objects that have members.
movies_t * pmovie;
pmovie->title is, for all purposes, equivalent to: (*pmovie).title

6.
Classes are an expanded concept of data structures: like data structures, they can contain data members,
but they can also contain functions as members.
empty parentheses cannot be used to call the default constructor:
Rectangle rectb;   // ok, default constructor called
Rectangle rectc(); // oops, default constructor NOT called

Remote debug on asset control

Same method to remote debug on asset control, Eclipse or other osgi based application.

Add the below on ac.desktop.ini (or Eclipse.ini):
-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000

Start the debug from Eclipse.

Tuesday, August 4, 2015

Australia trval

www.wotif.com
surfers paradise
apartment self contained
great barrier reef

Thursday, July 30, 2015

English collection

However, Chen was given his car back when another driver - who had been travelling behind him - handed over his dash cam footage that showed the woman ducking under the car after it stopped at the lights.
Police suspect that the old woman may have been planning to try and claim on insurance pay-out.
He posted online: “Whatever the reason I am just grateful that the other motorist was kind enough to provide the footage which cleared my name and sorted the matter out quickly.”

what do you want to be when you grow up?

A robber had broken into the house and was rummanging through my uncle's few belongings.

Monday, June 29, 2015

a weird issue detecting

a weird issue detecting:
Some db change and Java change is applied for the currency proxy. It works well on dit but no proxy no sit. I checked everything on SIT and it looks
good. Then I compared everything (DB tables/views/packages, Java, shell script, configuration, crontab) and they look good.
Finally, I noticed that there are minor difference the time stamp between the file log and the database time stamp.
Finally, the issue is proved that

Tuesday, June 16, 2015

No need to have the admin priviledge to install MinGW

No need to have the admin priviledge to install MinGW
1. Just download the latest mingw-get-setup.exe
2. Double click and a popup GUI will show up
3. Select base MinGW and g++ compiler (for me)
4. Add C:\MinGW\bin to the user's path (no admin on Win7)
5. create a helloworld.cpp on c:\MinGW\sources:
#include <iostream>

int main()
{
  std::cout << "Hello World!";
}
6. cd C:\MinGW\sources
   g++ helloworld.cpp -o helloworld.exe
7. Download Eclipse CDT and enjoy the C/C++ development
 
The best part is that you can put everthing into C:\MinGW, it's very clean.