Jump to content

Hello World

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
aurelABHR

aurelABHR

    Learning Programmer

  • Members
  • PipPipPip
  • 72 posts
Hello Experts in C++!
I need small example how writte well know Hello World code in C++.
So i need first open new window,then show text Hello Wold.
regards

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Google for:
"hello world" C++
to get numerous results.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
Hello World in C++

#4
aurelABHR

aurelABHR

    Learning Programmer

  • Members
  • PipPipPip
  • 72 posts
Hey dargueta this is console i need window example:D

#5
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
Here's a cross-platform example using wxWidgets:
// test.cpp

#include <wx/wx.h>

class MyFirstApplication
    : public wxApp
{
    public:
        bool OnInit();
};

class MyFirstFrame
    : public wxFrame
{
    public:
        MyFirstFrame(wxString title)
            : wxFrame(NULL, -1, title, wxDefaultPosition, wxDefaultSize)
        {
            wxStaticText *text = new wxStaticText(this, -1, wxT("Hello, World!"), 
                                                  wxDefaultPosition, wxDefaultSize);
            
            this->SetSize(text->GetSize());
        }
};

IMPLEMENT_APP(MyFirstApplication)

bool MyFirstApplication::OnInit()
{
    MyFirstFrame *frame = new MyFirstFrame(wxT("Hello, World!"));
    
    frame->Show(true);
    this->SetTopWindow(frame);
    
    return true;
}
And how to compile:
$ g++ test.cpp `wx-config --libs --cxxflags` -o test
I coded the constructor for the MyFirstFrame-class simple, so that it only accept the title in this example. In a real-world situation you would usually let it accept more parameters, like position, size and maybe also window decoration.

#6
aurelABHR

aurelABHR

    Learning Programmer

  • Members
  • PipPipPip
  • 72 posts
This is something oK.thanks

#7
MeTh0Dz

MeTh0Dz

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,119 posts
Don't come on here and ask people to make code for you, search the net there are plenty of resources.