Every C++ program must define an entry point in the form of a main
function .
Delete the existing file strom.cpp (right-click its name in the Solution Explorer, then choose Remove). Create a new file main.cpp (right-click Source Files folder, then choose Add > New Item…, click C++ File (.cpp)) and add the following code to it, saving the file when done.
#include <iostream>
#include "node.hpp"
#include "tree.hpp"
using namespace strom;
const double Node::_smallest_edge_length = 1.0e-12;
int main(int argc, const char * argv[]) {
std::cout << "Starting..." << std::endl;
Tree tree;
std::cout << "\nFinished!" << std::endl;
return 0;
}
Recall that the data member _smallest_edge_length
in the class Node
was declared to be static, so we must initialize it in a source code file, and main.cpp
is our only source code file, hence the line that sets _smallest_edge_length
to the very tiny value 1.0e-12
.
The main
function firsts announces that the program is starting to run (by displaying Starting...
to standard output), then creates a Tree
object having nodes made of Node
objects, then announces that the program is finished running just before returning 0 (the exit code 0 tells the operating system that the program ended normally).