Open ghostbody opened 8 years ago
Let me be the first one to leave some commets to +7 ta. Recently I modified my hosts file in my win7 os with ipv6 files and was able to access to google.hk. However, I can't make it in my VMware Ubuntu systerm. Can you tell me what should I do? (there are maybe some English grammer faults but I think +7 ta can understands it clearly :))
Well, I met the same problem, too. The reason is that the network configure of your VMware is not correct.
ipv6 does not support nat in ipv4, because ipv6's is a network protocol which promise that each device can get an ip address rather than NAT.
Solution: Share the same ip address with you host machine. Or just use a linux system without virtual.
@longjj
OK, thanks, I will try it in the following several days!
@ghostbody
@longjj Can you follow me? just want to have some followers 23333 damn it! how to use emoji...
Interesting...maybe you can also let +7 to follow you hhhh..... Ok, I have already followed you . _> Enjoy coding guy!
@mgsweet
@ghostbody why the document C is different when i push it to github?
eden died.I'm so sad~
@mgsweet Well, I have not known what the icon mean yet, but it looks so wired. Maybe an empty folder, I guess....
@KatharinaLin It works now.
@ghostbody
are you sure node& operator=(const node &another) { this->data = another.data; this->next = another.next; } in the list.hpp don't need to have a return?
@mgsweet Because I don't need a cascade call.
I want to ask a question:why the report of memory is different?
It's OK now .But I don't know why.
@KatharinaLin I have met this problem, too. And I think it's a problem of eden. Because I use valgrind to check and no problem found using "all checking mode". Maybe you can use --leak-check=full to try again.
o,thank you~
so nice~
I have met this problem before, but this time it seems different from the last time.I can't find the problem.Can you help me ?
I don't know why...
A small summary for 15 C++ learning
What's the problem with my program? Why eden fetch me a lot of error information?
Answer: Eden, the online judge system uses a memory check tool named "valgrind" for grading assignment. There are several kinds memory errors you will open meet.
1. Memory Leak: The picture below show this error. It's your mistake that a block of memory become unreachable when you take pointer operations. This will only take place with heap allocation when you are setting a pointer to point to another block of memory while ignoring the legacy memory.
For example, in a list:
The memory block which was pointed by pointer head is definitely lost after the assign operation above.
2. Invalid read or write of memory: This kind of mistake is very common because c++ compiler will not check invalid memory access. Mostly, you are accessing an element of an array of which the index is out of range.
For example:
a[5] is an invalid element of the array. And valgrind will throw "Invalid write of size 4.... Address 0x5202054 is 0 bytes after a block of size 20 alloc'd". This means that the address a+5 is not allocated by statement
int * a = new int[5]()
. Also you will get runtime error in this case.3. Condition jump or move depends on uninitialized variables. This means that some of your conditional statements, i.e. for loop, if statement or etc. use uninitialized variables.
For example:
First of all, if the programmer forget to call
delete a
, it will cause a memory leak error. Well, the if statement above uses a[0], which has not been initialized. Then valgrind will detect and report the error for you.4. Mismatched new/malloc and delete/free. As we all know, when you are writing c++ code using dynamic memory allocation, you are supposed to manage the heap memory by your self. New and delete are "paired operators" which means that when you call 3 of new, you should call 3 of delete after that.
For a mismatch example:(Tecent recruitment examination)
This will cause a mismatched error in valgrind. Why?Think about what's difference between new and malloc as well as delete and free? (hint: constructor and destructor)
How can I fix these issues?
Basically, you should know the concepts in c++ programming, or you will know nothing when you meet these issues.
After that:
Establishing good coding habits. A good coding style does not indicate that you pass the google style check in the system. This is not good enough.You should always be careful when you meet a pointer which is an annoying but powerful tool and you should remember to delete the pointer when you are using heap allocation to get memory.
Be careful to these parts of a class:
this == &another
or not.Later, if I have time, I will choose some codes from your exercises submissions to put here for you to have a discussion "What is good style of coding?"
valgrind
It's quite easy to use this tool, just compile you code and then run the program with a system argument which should be your executable program name.
or you can have more options, like to check full memory leak.
or
check
valgrind -h
for more details.you can see a lot of information after running the program.
Be patient when you meet errors. This is a test that must be experienced before you become a supper programmer in c++.
If you have any questions, please comment below. I do not open see my QQ because there are too many messages.
Or you can send me a email which is also filled with unread emails....
If you have any experience, you are more than welcome to make an issue.
Happy coding...