Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // File prog.cpp - main entry point:
- int main() {
- HelloWorld helloWorld;
- helloWorld.sayHello();
- return 0;
- }
- // File helloworld.h - class header File
- #ifndef HELLOWORLD_H // Prvent this file from being loaded twice
- #define HELLOWORLD_H
- class HelloWorld {
- public:
- HelloWorld(); // Default constructor
- HelloWorld(const HelloWorld&); // copy constructer
- ~HelloWorld(); // Destructor
- void sayHello(); // Some instant method
- };
- #endif
- // File helloworld.cpp - class code File
- #include <iostream>
- HelloWorld::HelloWorld() {} // nothing to init in this case
- HelloWorld::HelloWorld(const HelloWorld&) {} // no stuff here either
- HelloWorld::~HelloWorld() {} // no code to be executed on destruct
- void HelloWorld::sayHello() {
- std::cout << "Hello World" << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement