Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) MemberFunctionExample1

 

C++11STLQt CreatorLubuntu

 

member function example 1: Hello World is a member function example.

 

The class 'HelloWorld' has a single const member function called 'SayHelloWorld'. It is called in main, producing the same output as a Hello World program.

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppMemberFunctionExample1/CppMemberFunctionExample1.pro

 

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

#
#
# Type of compile
#
#

CONFIG(release, debug|release) {
  DEFINES += NDEBUG NTRACE_BILDERBIKKEL
}

QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -Weffc++

unix {
  QMAKE_CXXFLAGS += -Werror
}

 

 

 

 

 

./CppMemberFunctionExample1/main.cpp

 

#include <iostream>

struct HelloWorld
{
  void SayHelloWorld() const noexcept { std::cout << "Hello World\n"; }
};

int main()
{
  const HelloWorld h;
  h.SayHelloWorld();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml