(C++) MemberFunctionExample1
February 24, 2017 · View on GitHub
(C++) MemberFunctionExample1




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)
Lubuntu 15.04 (vivid)
Qt Creator 3.1.1
- G++ 4.9.2
Libraries used:
STL: GNU ISO C++ Library, version
4.9.2
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(); }