1. No recommendation when coding in VS Studio 2005? try to check whether you left some important punctuation, such as ") ] } ; " etc
2. try to use FileWriteTuple(ofstream& ofs, string line) instead of FileWriteTuple(ofstream ofs, string line), just some feeling, no reason.
3. getline(infile, line, '\n') function will also count the line if the last line of the file has an enter return.
4. for checking whether an element exist in a set or not, there is a function named set::count handle it. No need to write your own function.
Thursday, October 25, 2007
Saturday, February 10, 2007
Where C/C++ differ?
- Implicit assignment from void*: in C, is ok; in C++, not safe, cannot compile
- Freeing arrays: in C, use malloc and free for single elements and arrays; in C++, you much match calls to new/delete, new[]/delete[]
- Functions must be decleared before use
- struct: in C, you have to include keyword struct in order to declear a struct_instance; in C++, you don't have to do so.
- C++ has a much larger library: sometimes you want to compile a math heavy computation program, you could use gcc foo.c -lm/g++ foo.cc
- C didn't provide a boolean type, you could use enum to define.
- C++ may automatically add return 0 at the end of the main(); however in C you have to do it yourself.
- C requires define all the variables before a block of codes; C++ not necessary.
Subscribe to:
Posts (Atom)