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
Y

yellowine

@yellowine
About
Posts
48
Topics
20
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Derived class from a template base class
    Y yellowine

    If I have a c++ template class declared in Point.hpp file as below

    template <typename>
    class Point
    {
    ....
    }

    If I want a new class derived from the above class in Node.hpp file but the data type is specialized to be double:

    class Node: public Point<double>
    {
    ...
    }

    When I compile the codes, the compiler complains that in Node.hpp that the base class Point is undefined. I know that I have included Point.hpp in Node.hpp. Why that error? Or how can I derived a node class (which should be a non template class) from a template Point class with double data type?

    ATL / WTL / STL question c++ help

  • Efficiency question
    Y yellowine

    I have the following codes:

    double Length0(double x1, double y1, double z1, double x2, double y2, double z2)
    {
    double dx = x2 - x1;
    double dy = y2 - y1;
    double dz = z2 - z1;

    return (dx\*dx + dy\*dy + dz\*dz);
    

    }

    double Length1(double x1, double y1, double z1, double x2, double y2, double z2)
    {
    return ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1) + (z2 - z1)*(z2 - z1));
    }

    Assume all other conditions are the same, which one (Length0 or Length1) theoretically executes faster? A bit explanation is highly appreciated.

    C / C++ / MFC question

  • help: A C++ template question [modified]
    Y yellowine

    Thanks. I tried according to your suggestion and it worked. But i still didn't get it why GetBoundingBox() should be a const function? what if the return value is a pointer?

    ATL / WTL / STL help question c++

  • help: A C++ template question [modified]
    Y yellowine

    I have the following codes (partially copied for illustration) using template class: template struct _BoundingBox { T x0, x1, y0, y1; }; template class CMyObject { public: typedef struct _BoundingBox stBBOX; CMyObject() { Init(); // do class initialization here } CMyObject(const CMyObject &Obj) // copy constructor { // do some data copy here .... _Box = Obj.GetBountingBox(); } virtual ~CMyObject() {} public: stBBOX GetBoundingBox() { return _Box; } protected: stBBOX _Box; }; int main(argc, char* argv[]) { CMyObject obj1 CMyObject obj2(obj1); } After compile (using VC 2005, the compiler gave the following error message: error C2662: 'CMyObject::GetBoundingBox' : cannot convert 'this' pointer from 'const CMyObject' to 'CMyObject &' with [ T=int ] Conversion loses qualifiers However, if I change _Box = Obj.GetBountingBox(); to _Box = Obj._Box; in the copy constructor, the error disappears. Anyone knows what the problem is? Thanks.

    modified on Tuesday, February 24, 2009 5:18 PM

    ATL / WTL / STL help question c++

  • pointer help
    Y yellowine

    I have the following codes: void Fun(int *v1, int *v2); int *n1 = 0; int main(int argc, char* argv[]) { int *n2 = new int; *n2 = 3; Fun(n1, n2); delete n2; return 0; } void Fun(int *v1, int *v2) { v1 = v2; } After compiled and run, the value of n1 is supposed to the pointer value of v2 which contains an integer 3 after called Fun and before the delete statement. But actually not, n1 is still 0 after called Fun. why? Thanks.

    C / C++ / MFC help question

  • CDocManager::DoPromptFileName(...) error
    Y yellowine

    Tried step into debug, nIDSTitle seems to be the standard AFX_IDS_OPENFILE (61440). It seems the standard AFX_IDA_... are defined in afxres.rc, how how comes this file is not included in the project. Therefore it seems to be related to project setting to solve it. Just dunno. Any idea?

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

  • CDocManager::DoPromptFileName(...) error
    Y yellowine

    I have tried rebuild all and did not work...

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

  • CDocManager::DoPromptFileName(...) error
    Y yellowine

    I used Visual C++ 2005 to generate an MFC doc-view sample application. I got an strange error message when I try to open an previously save file in MFC in a static library. I have traced the problem and it was the codes in MFC provided docmgr.cpp below which caused the problem: BOOL CDocManager::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate) { CFileDialog dlgFile(bOpenFileDialog, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, NULL, 0); CString title; VERIFY(title.LoadString(nIDSTitle)); dlgFile.m_ofn.Flags |= lFlags; ... } The VERIFY(title.LoadString(nIDSTitle)) statement gives VERIFY's error. However, if I compiled the application in "Use MFC in a shared DLL". Then compile and build it, it can work without any problem! Anyone know what the problem is?

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

  • Dialog question
    Y yellowine

    It works. Thanks a lot.

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

  • Dialog question
    Y yellowine

    I am using MFC's CDialog derived class to do some lengthy task. I use a button to trigger the process. The problem I am having is: after I click the button, the lengthy task begins. However, after I switch to other programs, the dialog won't respond my click on it until the task is done. Is there any way I can do to get rid of the problem.

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

  • OpenGL and .NET Windows Forms application
    Y yellowine

    Does anybody know how to use OpenGL with .Net forms application in Visual C++ environment or any place I can take a look? Thanks.

    .NET (Core and Framework) c++ csharp winforms graphics game-dev

  • INT_PTR question
    Y yellowine

    I noticed that in VS 2005, the return values of GetCount method of CList and CArray and their derived classes are of INT_PTR. I am wondering why INT_PTR not int or long? To me, that is getting messy of MFC 7.0 or higher in dealing with data types. Thanks. -- modified at 16:05 Tuesday 28th March, 2006

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

  • Why VC++ .NET 2005 adds a function to a class in a different cpp file?
    Y yellowine

    It looks odd to me that VC++ .NET 2005 adds a new function to a different cpp file. I have a folder (named as Dialogs) which stores a bunch of header and cpp files of dialogs in a project (MyApp) folder. When I right click mouse in Class View to add a new function to MyDialog class whose header and cpp files are in Dialogs folder within MyApp folder and click OK, Visual Studio automatically adds the definition of the function to the correct header file, however, it adds the function implentation codes to a new cpp file right in the MyApp folder instead of MyDialog with the same name of the class. In order to have VS correctly place the codes to the cpp file under Dialogs folder, I have to specified the location of cpp file in the Add-member-function-wizard. This means that every time I want to add a function to a class whose cpp file in NOT directly under the default project folder (MyApp in this case), I have to explicitly specify location of its cpp file . This is annoying and is NOT the behavior of VS 6.0. Anyone knows a way to fix this or this is the way VS .NET 2005 is?

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

  • ifstream issue in Visual C++ .NET 2005
    Y yellowine

    Got it. Thanks.

    C / C++ / MFC c++ help csharp

  • ifstream issue in Visual C++ .NET 2005
    Y yellowine

    Thanks for that hint. Now I think the original post has been modified as it should.

    C / C++ / MFC c++ help csharp

  • ifstream issue in Visual C++ .NET 2005
    Y yellowine

    I got an error for the following codes regarding ifstream: #include <fstream> #include <afxtempl.h> class CMyclass: public CObject { public: CMyclass(); DECLARE_SERIAL (CMyclass) virtual ~CMyclass(); public: // // other methods here // BOOL OnLoadData(ifstream& inFile); // load data from a file stream }; When compile this header, I got "error C2061: syntax error : identifier 'ifstream'" message. I am wondering why 'ifstream' is NOT defined in <fstream> (it should be as msdn says). Thanks. -- modified at 16:31 Tuesday 14th March, 2006

    C / C++ / MFC c++ help csharp

  • How to convert CString to char* in Visual C++ .NET 2005
    Y yellowine

    I use the char* hello1 for an OpenGL function which take strictly a char* parameter. and s wchar_t variable will not work for the gl function.

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

  • How to convert CString to char* in Visual C++ .NET 2005
    Y yellowine

    I am having trouble converting a CString variable to a char* variable below: CString hello("CString"); char* hello1=new char[hello.GetLength()+1]; _tcscpy(hello1, hello); Error 1 error C2664: 'wcscpy' : cannot convert parameter 1 from 'char *' to 'wchar_t *' d:\projects\c++.net\test3\test3 Why it is wrong? Thanks in advance. -- modified at 15:54 Thursday 9th March, 2006

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

  • Help: VS.NET 2005 Help Broken?
    Y yellowine

    I have tried that. The real issue is that sometimes the F1 help works, sometimes not. Any idea?

    C / C++ / MFC csharp c++ visual-studio help tutorial

  • Help: VS.NET 2005 Help Broken?
    Y yellowine

    I just installed the VS .NET 2005 Professional and the accompanied MSDN library in FULL. I am using them for a VC++ project and am having trouble with the local Help functionality: F1 help is broken. That is, if I position the cursor over a keyword (for example OnEraseBkgnd) and hit F1, it always displays the topic-not-found page. Any suggestions appreciated.

    C / C++ / MFC csharp c++ visual-studio help tutorial
  • Login

  • Don't have an account? Register

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