
C++
Achilles_K
这个作者很懒,什么都没留下…
展开
-
C++ Knowledge: The separate type for address
#include int main(){ using namespace std; int hand[4] = {1,2,3,4}; int things[] = {1,5,3,8}; int i, num = sizeof(things) / sizeof(int); cout cout cout原创 2013-09-29 22:01:45 · 387 阅读 · 0 评论 -
Parameters, Arguments
Quoted from the >:Arguments are the initializers for a function's parameters. The first argument initializes the first parameter, the second argument initializes the second parameter, and so on. Alt转载 2014-01-06 10:13:42 · 503 阅读 · 0 评论 -
Automatic Objects and Local static Objects
Automatic ObjectsThe objects that correspond to ordinary local variables are created when the function's control path passes through the variable's defintion. They are destroyed when control passes转载 2014-01-06 11:08:39 · 710 阅读 · 0 评论 -
A difference between decltype and auto?
Quote from the Books: On the other hand, the dereference operator is an example of an expression for which decltype returns a reference. As we've seen, when we dereference a pointer, we get the obje转载 2013-12-22 11:06:37 · 635 阅读 · 0 评论 -
the first glance at the try block
C++ primer introduce some functions of try block.. But it haven't a instance..So I get the first example.#include #include #include using namespace std;int main(){ float num1, num2, resu原创 2014-01-05 17:08:43 · 508 阅读 · 0 评论 -
overloaded Function in c++
The overloaded function is an important concept in C++.What's the definition?Function that have the same name but different parameter lists and that appear in the same scope are overloaded. Genera转载 2014-01-08 14:35:38 · 1127 阅读 · 0 评论 -
Pointer to the function
Pointer to the function?It appears on the page.247. I had never get in touch with this concept before. Let me make some records.A function pointer is just that -- a pointer that denotes a function原创 2014-01-09 12:28:46 · 515 阅读 · 0 评论 -
Today is boring... I register a new account in stackoverflow
Remark it ~Today, i register a new account in stackoverflow.The csdn is nice as the stackoverflow.That's enought for me, a beginner in program原创 2014-01-09 09:30:17 · 547 阅读 · 0 评论 -
a puzzle: "decltype definition"
Today, I found a puzzle of "decltype definition"... it's relative to the reference...example:#include int main(){const int ci = 0, &cj = ci;decltype(ci) x = 0;decltype(ci) y = x;std::cou原创 2013-12-19 12:27:02 · 435 阅读 · 0 评论 -
The first class after reading the section7.1 <<C++ primer>>
Today, I start learning the class in C++.. It's really hard to get it.So slow my step into it...I decided to make some records at first.The books mention a simple class on Page 73:struct Sales_da原创 2014-01-09 21:16:00 · 756 阅读 · 0 评论 -
the difference between : cbegin(cend) and begin(end)
cbegin(cend):Return const_iterator to beginningReturns a const_iterator pointing to the first element in the container.A const_iterator is an iterator that points to const content. This iter转载 2013-12-26 09:36:17 · 8338 阅读 · 0 评论 -
tips for subscript operator
Quote from the >:"""int *p = &ia[2]; // ia[] is a int-type array, it contains 5 elements.int j = p[1];int k = p[-2];This last example points out an imiportant difference between arrays an转载 2013-12-27 17:14:19 · 615 阅读 · 0 评论 -
Name lookup for Class Member Declarations
It's quoted from the >"""....typedef double Money;string bal;class Account {public: Money balance() { return bal; }private: Money bal;//.....};When the compiler sees the decl转载 2014-01-22 15:59:07 · 637 阅读 · 0 评论 -
A Important Note
"""ADVICE: USE CONSTRUCTOR INITIALIZERS-------------------------------------------------------------------------------------------------------------------------------------------------------------原创 2014-01-24 11:08:00 · 625 阅读 · 0 评论 -
Constructors__<<C++ primer>>
"""Classes control object initialization by defining one or more special member functions known as contstructors. The job of a constructor is to initialize the data members of a class object. A cons转载 2014-01-17 14:39:23 · 564 阅读 · 0 评论 -
C++ primer practice: 5.4.1 (Exercises section) answer
The is an answer (not the only one) for exercise 5.4.1:Remark it for my own path for program path#include #include using namespace std;int main(){ vector sVect; vector iVec; unsigned i原创 2014-01-03 10:36:28 · 939 阅读 · 0 评论 -
tips for constexpr and Constant Expressions
A constant expression is an expression whose value cannot change and that can be evaluated at compile time.A typical characteristic: the constant express will be evaluated at compile time, not at ru原创 2013-12-18 16:33:08 · 640 阅读 · 0 评论 -
A puzzle for me (cookie)
Today, i met a problem.. I'm a new man in C++ programer.So it's reserved for me... I believe I would get it.#include using nameapce std;int main(){string str;auto sp = str.begin(); /// st原创 2014-01-02 16:28:37 · 572 阅读 · 0 评论 -
c++ trap: the character array & string
#include #include int main(){ using namespace std; char charr1[20]; char charr2[20] = "jaguar"; string str1; string str2 = "panther"; cout cin >> charr1;原创 2013-09-30 21:09:53 · 727 阅读 · 0 评论 -
c++ basic thoughts: char array
//strtype3.cpp .. more string class features#include #include #include // C-styple string libraryint main(){ using namespace std; char charr1[20]; char charr2[20]原创 2013-10-01 10:51:33 · 523 阅读 · 0 评论 -
C++ :: delete
It's important to make a distinction between:1. "Pointer" as a variable residing on the stack. The name tempb refers to one such variable.2. "Pointer" as an integer value that refers to a memory l转载 2013-10-08 10:41:58 · 443 阅读 · 0 评论 -
the trap: c++'s array
#include int main(){ using namespace std; int yam[3]; yam[0] = 7; yam[1] = 8; // why it can't report the warnning? when yam[3] is existed? yam[3] = 6; //原创 2013-09-29 21:03:17 · 470 阅读 · 0 评论 -
Records: The concepts of cin.get..
If you are n't cookie, please skip it ... Thanksfrom now on, I get two methods or ways to use it:cin.get(name,ArSize).get()cin.get(ch);It's really confuse me right now. I Know C language, the原创 2013-10-12 09:53:46 · 496 阅读 · 0 评论 -
c++: the hint of pointer
Okay. Today i get a new concept about pointer:I usually treat pointer as a tag of address. But now I think i made some mistakes.First of all: when a pointer point to the the first of address原创 2013-10-09 13:11:10 · 464 阅读 · 0 评论 -
An answer for C++ excercise
It's shown on the C++ prime plus:You would see it if you follow the step ..I just want make a record, it takes me some times... On page: 301The excercise:Write a program that reads inp原创 2013-11-08 09:26:45 · 606 阅读 · 0 评论 -
Using a Range for with Multdimensional Arrays.
size_t cnt = 0;for (auto &row: ia) for (auto &col : row) { col = cnt; ++cnt;}In the previous example ,we used frefernces as our loop control variables because we wanted to change转载 2013-12-28 20:42:05 · 538 阅读 · 0 评论 -
C++ Keywords Alternative Operator Names
C++ Keywords:alignascontinuefriendregistertruealignofdecltypegotoreinterpret_casttryasmdefaultifreturntypedefautodeleteinlineshorttypeid转载 2013-12-16 14:34:51 · 671 阅读 · 0 评论 -
summary: sizeof
The result of applying sizeof depends in part on the type involved:*) sizeof char or an expression of type char is guaranteed to be 1.*) sizeof a reference type returns the size of an object of th转载 2013-12-30 21:23:06 · 505 阅读 · 0 评论 -
An interested program for cookie
#include int me = 42;int me2 = 42;int main(){std::cout << me << std::endl;me = 33;std::cout << me << std::endl;std::cout << ::me << std::endl;int me2 = 33;std::cout << me2 << std::endl;原创 2013-12-16 15:50:46 · 475 阅读 · 0 评论 -
The pointers in C++ primer
What's the difference between the references and pointer?the common:they are used for indirect access to other objects.the differences:1.) a pointer is an object in itw own right. Pointers can转载 2013-12-17 10:01:10 · 417 阅读 · 0 评论 -
Quoted from Microsoft Website: reinterpret_cast Operator
reinterpret_cast:Allows any pointer to be converted into any other pointer type. Also allows any integral type to be converted into any pointer type and vice versa.form: reinterpret_cast ( ex转载 2013-12-31 14:24:45 · 499 阅读 · 0 评论 -
lvalue and rvalue
Every C++ expression is either an lvalue or an rvalue. An lvalue refers to an object that persists beyond a single expression. You can think of an lvalue as an object that has a name. All variables, i转载 2013-12-30 15:01:00 · 975 阅读 · 0 评论 -
A story of declaration and defintion (C++)
"""To support separate compilation, c++ distinguishes between declarations and definitions. A declaration makes a name known to the program. A file that wants to use a name defined elsewhere include转载 2015-01-17 21:32:23 · 585 阅读 · 0 评论