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
W

W Hammer sledge

@W Hammer sledge
About
Posts
9
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to read a file line-by-line?
    W W Hammer sledge

    You can use getline()

    #include

    void main()
    {
    char buffer[256];
    ifstream file;
    file.open("c:\\autoexec.bat", ios::in | ios::nocreate);

    if (file.good())
    {
    while(file.peek() != EOF)
    {
    file.getline(buffer,255);
    cout << buffer << endl;
    }
    file.close();
    }
    else
    cout << "error opening autoexec.bat" << endl;

    }

    the default delimiter for getline is \n, see msdn for more details. Hope this helps sledge

    C / C++ / MFC c++ tutorial question

  • how to convert a project to non UNICODE
    W W Hammer sledge

    Try changing the configuration of your project to win32debug or win32release. sledge

    C / C++ / MFC help tutorial career

  • Define triangle class
    W W Hammer sledge

    OK, let me see, if i understood you correctly. You want to use an overloaded operator << . But what you have done, is only using the normal output of an float. The overloading would look like this:

    ostream& operator<< (ostream& ostr, CTriangle& triangle)
    {
    ostr << "Side1 = " << triangle.side1 << endl
    << "Side2 = " << triangle.side2 << endl
    << "Side3 = " << triangle.side3 << endl;
    return ostr;
    }

    The overloaded operator== looks like this:

    bool operator ==(const CTriangle& tri1, const CTriangle& tri2)
    {
    if (tri1.side1 == tri2.side1
    && tri1.side2 == tri2.side2
    && tri1.side3 == tri2.side3)
    return true;
    else
    return false;
    }

    My personal advice: You should divide your program into three files. ----------------------- First file - a file containing the declaration of the triangle class. Name this file triangle.h !! Remember that triangle is a class, so name the class CTriangle. !! ----------------------- Second file - Name this file triangle.cpp include your triangle.h by using #include "triangle.h" Now put all the definitions of your CTriangle class in here (for instance yout get-functions etc. and the overloaded operators). Don't forget neccessary inclusions like iostream.h ----------------------- Third file - name this file main.cpp include your triangle.h by using

    #include "triangle.h"
    #include <iostream.h>

    void main()
    {
    CTriangle triangle1, triangle2(5.0, 4.0, 3.0), triangle3(6.0, 4.0, 4.0);
    cout << "Display triangle 1:\n";
    cout << triangle1 ;

    cout << "Display triangle 2:\n";
    cout << triangle2 ;

    cout << "Display triangle 3:\n";
    cout << triangle3;

    if (triangle2 == triangle3)
    cout << "identical" << endl;
    else
    cout << "not identical" << endl;
    <

    }

    I havent compiled it, but this should work. Test it by changing the values of the triangle2 and triangle3. Hope this helps sledge

    C / C++ / MFC help

  • This is not visual, nor C++
    W W Hammer sledge

    If you want to test code from Kerningham and Ritchie, you can use VC of course. All you have to do is (VC6) First: click on File - New you can now choose the type of project you want to create select WIN32console application name it test (the IDE will append .dsw) click OK Second: Select File - New again you can now choose then type of file vou want to create select sourcecode (.cpp) name it main (the IDE will append .cpp) click OK Now you can cut and paste your sourcecode to the main.cpp file and compile it. (usually the first test would be compiling "Hello World") sledge

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

  • Question about &quot;!&quot;.
    W W Hammer sledge

    The ! means NOT. If you have a boolean value like true the operator ! will make it to false. if nStatus has the value zero, the term wil be true. !(nStatus == 0) will make it false. It is the same if you write nStatus != 0. sledge

    C / C++ / MFC question

  • mfc42u.lib ?
    W W Hammer sledge

    The u stands for unicode. You have to change the configuration of your project to win32release or win32debug. Another way to fix this will be installing the unicode versions of mfc. Hope this helps sledge

    C / C++ / MFC help css question

  • ComboBox
    W W Hammer sledge

    Thanks, as i mentioned, I know that it works, if i put this in InitDialog (or OnInitDialog() ) . But why does it work with a static control or a textbox? sledge

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

  • ComboBox
    W W Hammer sledge

    :confused:I am using the MFC. I have created a dialog, which has a static control and a comboBox, both elements have membervariables. I want to show the dialog like this: .... CMyDialogDlg mydialog; mydialog.m_static.SetWindowText("this works"); mydialog.m_combo.AddString("this crashes"); mydialog.DoModal(); .... There is no problem setting the windowtext of the staticcontrol. But if i use AddString before the dialog is shown by DoModal(), it crashes. If i use AddString in InitDialog() , it works. Can you explain me why?? what have i forgotten?

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

  • CToolBar in a dialog?
    W W Hammer sledge

    Maybe this will help you http://www.codeproject.com/dialog/CDialogEx.asp sledge

    C / C++ / MFC 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