Code Monkey home page Code Monkey logo

codenote's Introduction

CodeNote

There is something valueable for me,which took me much time off and brought much experience to me.

1.Something about Wreorder warning.

When we write constructor's implemention,we should pay attention to the order that we declare variables.

eg: class Box { private: int a; int b; public: Box(int n):b(n++),a(n++){} void show(){ cout << a << b << endl; } };

There, we write a class called Box.When we define a Box instantiate like this: Box k(3), how much do you think the value of a and b? The answer is that a equal to 3 and b equal to 4. although we write the initializtion like this:b(n++),a(n++),but the order initializing them is the order what we declare them.

2.Why can template only be implementated in header file?

When I use a header file to write template class,and the implementation in cpp,there is many errors like this:undefined reference to .... After that,I look up about much time,but no satisfied answer(which says not including .h to the main cpp). Last,stackoverflow gives me a perfect answer,so I want to share the URL:http://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file

and the reason is that although we write implementation in cpp,the code won't be created by compiling that cpp file.

eg:there are some files. foo.h declares the interface of class MyClass declares the interface of class Box foo.cpp defines the implementation of class MyClass defines the implementation of class Box bar.cpp uses MyClass uses Box

When foo.cpp is compiled,the corresponding code won't be generated.So when compiler compiles bar.cpp and wants to create a MyClass,it can't see MyClass(can only see the interface in foo.h) and create Myclass.However,the Box's code can be created.Because when compiling foo.cpp,the code of Box has already been created.

3.About rebase(and relocation)

4.About PEX_LDR_DATA and LOD_MODULE in PE(MASM32)

codenote's People

Contributors

co-neco avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.