Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
F

Falconapollo

@Falconapollo
About
Posts
103
Topics
50
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • C++ 11 std::unique_ptr related compiling error
    F Falconapollo

    I'm stuck here on how to compile the following code, i need to put a struct which contains std::unique_ptr into std::map, but i always get the error message, anybody can help me?

    Quote:

    e:\console.cpp(21): error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>' 1> with 1> [ 1> _Ty=int 1> ] 1> d:\programfiles\vs 2010\vc\include\memory(2347) : see declaration of 'std::unique_ptr<_Ty>::unique_ptr' 1> with 1> [ 1> _Ty=int 1> ] 1> This diagnostic occurred in the compiler generated function 'Baa::Baa(const Baa &)' 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:01.28 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    here is my code:

    #include
    #include
    #include
    #include

    struct Baa {
    std::unique_ptr x;

    Baa() {
    }
    
    Baa(Baa&& o)
    {
    	x = std::move(o.x);
    }
    Baa operator = (Baa&& param)
    {
    	x = std::move(param.x);
    	return \*this;
    }
    

    };

    int main()
    {
    std::map sheep;
    Baa ba;
    sheep[0] = ba;
    }

    ATL / WTL / STL help c++ visual-studio performance tutorial

  • how to pass a function which has variable arguments as template argument?
    F Falconapollo

    I want to write a adapter which can convert non static member functions to C-sytle function pointers. Here is what I got now(see the following code snippet), but the current solution is not general. I want to make

    int (T::*Func)(int)

    accept variable arguments. but i'm stuck here? anybody can help me? and it's necessary to make

    int f()

    and

    int display

    have the same signature. The final goal is Interfacing C++ member functions with C libraries.

    class StoreVals
    {
    int val;
    public:
    int display(int k) { cout << k << endl; return 0; }
    };

    template
    class CObjectT
    {
    public:
    /*
    the signagure of f(...) should change by the argument of template. they must be the same, but i don't know how to achieve this goal
    */
    static int f(int i)
    {
    T obj;
    return (obj.*Func)(i);
    }
    };

    void main()
    {
    CObjectT::f(7);
    auto function_t = &CObjectT::f;
    cout << typeid(function_t).name() << endl; // now it's a c-style function pointer
    }

    C / C++ / MFC help c++ tutorial question lounge

  • how can use a non-static class member function as the custom deleter of std::unique_ptr?
    F Falconapollo

    When I attempt to set custom deleter of std::unique_ptr, I got this error: .\src\iMoney.cpp(5): error C2664: 'std::unique_ptr<_Ty,_Dx>::unique_ptr(HINSTANCE__ *,void (__cdecl *const &)(HMODULE))' : cannot convert parameter 2 from 'void (__thiscall iMoney::* )(HMODULE)' to 'void (__cdecl *const &)(HMODULE)' 2> with 2> [ 2> _Ty=HMODULE, 2> _Dx=void (__cdecl *)(HMODULE) 2> ] 2> Reason: cannot convert from 'void (__thiscall iMoney::* )(HMODULE)' to 'void (__cdecl *const )(HMODULE)' 2> There is no context in which this conversion is possible 2> 2>Build FAILED. anybody can help me? Here is my code snippet:

    //this is my non-static class member variable
    std::unique_ptr m_ptrModule;

    void iMoney::freeLib(HMODULE hModule)//this is the non-static class member function
    {
    m_pThisApp->FreeLibrary(hModule);
    }

    //this my constructor
    iMoney::iMoney(CReader_App* pApp)
    : m_pThisApp(pApp)
    , m_ptrModule(nullptr, &iMoney::freeLib)
    {
    //hello money, i love you so much~
    }

    C / C++ / MFC help c++ question

  • why can't I use std::shared_ptr & std::unique_ptr like this? just got crash
    F Falconapollo

    CPallini wrote:

    Scenario 1 doesn't 'crash' on my system.

    I'm using Visual Studio 2013.

    C / C++ / MFC csharp visual-studio question

  • why can't I use std::shared_ptr & std::unique_ptr like this? just got crash
    F Falconapollo

    I'm using Visual Studio 2013. I don't konw why get crash in these following scenarios. What am I missing? Crash in this function:

    extern "C" _CRTIMP int __cdecl _CrtIsValidHeapPointer(
    const void * pUserData
    )
    {
    if (!pUserData)
    return FALSE;

        if (!\_CrtIsValidPointer(pHdr(pUserData), sizeof(\_CrtMemBlockHeader), FALSE))
            return FALSE;
    
        return HeapValidate( \_crtheap, 0, pHdr(pUserData) );
    

    }

    Scenario 1:

    std::shared_ptr foo()
    {
    std::shared_ptr p(new int(10));
    size_t cnt = 10;
    while (cnt--)
    p.get()[cnt] = roll_die();

    return p;                   
    

    }

    void func(int* ptr, size_t cnt)
    {
    while (cnt--)
    {
    cout << ptr[cnt] << endl;
    }
    }

    void main()
    {
    std::shared_ptr u_ptr = nullptr;
    u_ptr = foo();
    func(u_ptr.get(), 10);
    }

    Scenario 2:

    std::unique_ptr foo()
    {
    std::unique_ptr p(new int(10));
    size_t cnt = 10;
    while (cnt--)
    p.get()[cnt] = roll_die();

    return p;                   
    

    }

    void func(int* ptr, size_t cnt)
    {
    while (cnt--)
    {
    cout << ptr[cnt] << endl;
    }
    }

    void main()
    {
    std::unique_ptr u_ptr = nullptr;
    u_ptr = foo();
    func(u_ptr.get(), 10);
    }

    C / C++ / MFC csharp visual-studio question

  • how to design the architecture?
    F Falconapollo

    um...you might misunderstood me,i meants it's inconvenicent to edit *.rc file directly, for instance, adding dialog, adding strings, adding icons... it's even more inconvenient to use function: UpdateResource...

    C / C++ / MFC c++ design algorithms architecture help

  • how to design the architecture?
    F Falconapollo

    Thank you for your quick reply. One more question: what if i modify our resources more frequently? it seems unconvenient to embed resources into static lib or exe, because i can't edit them directly...

    C / C++ / MFC c++ design algorithms architecture help

  • how to design the architecture?
    F Falconapollo

    At first, thank your for your reply. yes, you are right. because it should be a single EXE without any DLLs. >>it is even possible to embed the resource only DLL into the EXE itself. could you explain how to do it? If successfully do it, how can submodule access the resource? >>If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself. as far as i can see, it's not possible to embed resources into static library directly, could you explain your idea?

    C / C++ / MFC c++ design algorithms architecture help

  • how to design the architecture?
    F Falconapollo

    At first, let me describe our current architecture: Our project is based on MFC multiple doc view, and the project contains many submodules. The submodule contains two projects: one is a resource-only prject(dll), and another is a static library project. We extract resources from the dll(generated by resource-only project), then generate a *.cpp file which contains alll the resource data, include the *.cpp into static project. After linking with the static library, the Main Frame must use some helper functions to extract resources from *.cpp when it must use the resource from submodule. Now I want to find a better architecture to replace the current one, because its complexity of managing resource is sooo high. Anybody can help me? I'm not sure these words can make you understand me correctly?

    C / C++ / MFC c++ design algorithms architecture help

  • good algorithm to determine if there are overlapping in multiple rectangles
    F Falconapollo

    Suppose we represent rectangle with CRect(MFC), its edges is parallel to Ox and Oy. now we have N rectangles(N might be a very large number, for instance N = 9999). Now I want to determine whether there is(are) overlapping in these rectangles, of course I want the best algorithm. Anybody can help me?

    C / C++ / MFC c++ algorithms help question learning

  • what's the point of auto_ptr & unique_ptr?
    F Falconapollo

    I just can't understand the meaning of unique_ptr or auto_ptr, as we all know, once the parameter gets out of its scope, we won't get memory leaks. However, is it a better idea if I create the parameter on the stack rather on the heap. I don't see its advantage over normal parameters. If we really need to create parameters on the heap, then we must use '

    new

    ' operator, right? Here is a little code snippet:

    class Base
    {
    public:
    Base()
    {
    cout << "Base::()" << endl;
    }
    virtual ~Base()
    {
    cout << "~Base()" << endl;
    }

    virtual void iPhone()
    {
    	cout << "I'm iPhone5s" << endl;
    }
    

    };

    class Derive : public Base
    {
    public:

    Derive()
    {
    	cout << "Derive()" << endl;
    }
    
    virtual void iPhone()
    {
    	cout << "I'm iPhone 6" << endl;
    }
    
    virtual ~Derive()
    {
    	cout << "~Derive()" << endl;
    }
    

    };

    void main()
    {
    {

      auto\_ptr<Base> ptr(new Derive());//a foolish idea to do so?
      ptr->iPhone();
    
      Derive d;//isn't it better?
      Base\* base = &d;
      base->iPhone();
    

    }
    }

    C / C++ / MFC ios data-structures performance question

  • std::wcout can't print out Arabic chars and some mathmatical symbols
    F Falconapollo

    Recently I want to find a general solution for std::wcout so that it can print out all unicode strings. but, after poking around on google, i can't find useful. I'm stuck here, anybody can help me? _setmode(_fileno(stdout), _O_U16TEXT); won't work as expected. Here is my current code snippet:

                auto previousMode = \_setmode(\_fileno(stdout), \_O\_U16TEXT);
    	std::wifstream wifs;
    	wifs.imbue(std::locale(wifs.getloc(), new std::codecvt\_utf16));
    	wifs.open(L"F:\\\\重要网址.txt", std::ios\_base::binary);
    
    	std::wstring line;
    	std::getline(wifs, line);
    	
    	wcout << line << endl;
    	wifs.close();
    
    	wcout << endl;
    	cout << "∦" << endl;
    
    	std::wofstream wofs;
    	wofs.imbue(std::locale(wifs.getloc(), new std::codecvt\_utf16));
    	wofs.open(L"F:\\\\iMoney.txt", std::ios\_base::binary | std::ios\_base::ate);
    	wofs << line << endl;
    	wofs.close();
    	//it's important to restore mode to previous, otherwise std::cout will cause crash
    	\_setmode(\_fileno(stdout), previousMode);
    

    and here is some symbols to test your slution before post here: ∀, ∁, ∂, ∅, ∰, ∵, ∺, ⊙, ⋾, ⋻, ⋱, ⋭, ⋣, ⋧ Arabic: لطيفة الطقس اليوم

    C / C++ / MFC help ios question lounge

  • so confused. Should I learn Android development? if so, where should I start?
    F Falconapollo

    no, i hate QT

    C / C++ / MFC c++ career csharp android

  • so confused. Should I learn Android development? if so, where should I start?
    F Falconapollo

    wow, over 30+ years experience. it's almost impossible to find such a person in China, we have fall behind for a long time. are you a manger?

    C / C++ / MFC c++ career csharp android

  • so confused. Should I learn Android development? if so, where should I start?
    F Falconapollo

    excuse me, 30+? you mean 300k dollars per year? I'm from China, work in Beijing.

    C / C++ / MFC c++ career csharp android

  • so confused. Should I learn Android development? if so, where should I start?
    F Falconapollo

    may i know your salary? PS: i'm from Beijing, China.

    C / C++ / MFC c++ career csharp android

  • so confused. Should I learn Android development? if so, where should I start?
    F Falconapollo

    thank you so much for the long response~ it's a good answer.

    C / C++ / MFC c++ career csharp android

  • so confused. Should I learn Android development? if so, where should I start?
    F Falconapollo

    I am a C++ programmer(based on Visual Studio-MFC, Win32). I have 3-year work experience, now i'm so confused when search jobs at monster.com. So many Android job chances, and very few Windows C++ jobs. And the salary of Android is much better than VC++. To my dismay, Microsoft had fooled a lot of people, its technologies uupdated frequently and many of them are out of date, like Visual Basic, SilverLight, MFC, FrontPage, Expression Studio and so on. So confused about my situation, should I learn Android or go on learning MFC/Win32 or Linux C++ development? If should I learn Android, where should I start? How long will it take to make me a Anroid programmer?(If I want to find a Android job) I want to hear your recommentations.

    C / C++ / MFC c++ career csharp android

  • [MFC]no subclass, no derivation, just redirect one function of CButton, is it possible?
    F Falconapollo

    then, how about Hook?

    C / C++ / MFC c++ json question

  • [MFC]no subclass, no derivation, just redirect one function of CButton, is it possible?
    F Falconapollo

    As shown below, there are a few functions in CButton, but i want to change its behaviour by dealing with

    virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)

    . Yes, just this one and only one functon. It would generate more code than expected if I derive a class from CButton. I wonder if it possible to process this function without Subclass, and not use derivation. If so, how? Remarks: I must use MFC, it's so hard to use pure Win32 API.

    class CButton : public CWnd
    {
    DECLARE_DYNAMIC(CButton)

    // Constructors
    public:
    CButton();
    virtual BOOL Create(LPCTSTR lpszCaption, DWORD dwStyle,
    const RECT& rect, CWnd* pParentWnd, UINT nID);

    // Attributes
    UINT GetState() const;
    void SetState(BOOL bHighlight);
    int GetCheck() const;
    void SetCheck(int nCheck);
    UINT GetButtonStyle() const;
    void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE);

    HICON SetIcon(HICON hIcon);
    HICON GetIcon() const;
    HBITMAP SetBitmap(HBITMAP hBitmap);
    HBITMAP GetBitmap() const;
    HCURSOR SetCursor(HCURSOR hCursor);
    HCURSOR GetCursor();
    

    #if (_WIN32_WINNT >= 0x501)
    AFX_ANSI_DEPRECATED BOOL GetIdealSize(_Out_ LPSIZE psize) const;
    AFX_ANSI_DEPRECATED BOOL SetImageList(_In_ PBUTTON_IMAGELIST pbuttonImagelist);
    AFX_ANSI_DEPRECATED BOOL GetImageList(_In_ PBUTTON_IMAGELIST pbuttonImagelist) const;
    AFX_ANSI_DEPRECATED BOOL SetTextMargin(_In_ LPRECT pmargin);
    AFX_ANSI_DEPRECATED BOOL GetTextMargin(_Out_ LPRECT pmargin) const;
    #endif // (_WIN32_WINNT >= 0x501)

    #if ( _WIN32_WINNT >= 0x0600 ) && defined(UNICODE)
    CString GetNote() const;
    _Check_return_ BOOL GetNote(_Out_z_cap_(*pcchNote) LPTSTR lpszNote, _Inout_ UINT* pcchNote) const;
    BOOL SetNote(_In_z_ LPCTSTR lpszNote);
    UINT GetNoteLength() const;
    BOOL GetSplitInfo(_Out_ PBUTTON_SPLITINFO pInfo) const;
    BOOL SetSplitInfo(_In_ PBUTTON_SPLITINFO pInfo);
    UINT GetSplitStyle() const;
    BOOL SetSplitStyle(_In_ UINT nStyle);
    BOOL GetSplitSize(_Out_ LPSIZE pSize) const;
    BOOL SetSplitSize(_In_ LPSIZE pSize);
    CImageList* GetSplitImageList() const;
    BOOL SetSplitImageList(_In_ CImageList* pSplitImageList);
    TCHAR GetSplitGlyph() const;
    BOOL SetSplitGlyph(_In_ TCHAR chGlyph);
    BOOL SetDropDownState(_In_ BOOL fDropDown);

    // Sets whether the action associated with the button requires elevated permissions.
    // If elevated permissions are required then the button should display
    
    C / C++ / MFC c++ json question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups