// NOTE: We can comment out the variable names of the arguments if we do not use these variables in the code. This will prevent the compiler warning: 
// warning: unused parameter `argc' [-Wunused-parameter]
int main(int /*argc*/, char** /*argv*/) {
  
  SM_INFO_STREAM("Hi, I am a simple example program using the ExampleClass.");

  ExampleClass exampleClass; // Not initialized yet
  
  // We know that exampleClass.getA() will throw because it is not initialized yet. Let's catch this exception here, so we can continue with our program.
  try {
    
    double a = exampleClass.getA();
    SM_INFO_STREAM("a is " << a);
    
  } catch (const std::exception& e) {
    SM_FATAL_STREAM(e.what());
    SM_INFO("I caught an exception. In a real program you probably do not want to continue. Here we do to show some other examples.");
  }
  
  exampleClass.initialize(1.0, 2.0);
  SM_INFO_STREAM("Example class initialized: a = " << exampleClass); // This uses the custom stream operator
  
  // TODO: Initialize with a property tree, how to get path to file?
//   i=system("rospack find example_package");
//   boost::filesystem::path configFile();
//   sm::BoostPropertyTree propertyTree;
//   propertyTree.loadInfo(configFile);
//   exampleClass.initializeWithPropertyTree(propertyTree);
//   SM_INFO_STREAM("I initialized the ExampleClass with the property tree, now Example class is: " << exampleClass); // This uses the custom stream operator
  
  SM_INFO_STREAM("Example program terminated successfully");
  return 0;

}
Exemple #2
0
int main()
{
    TrialTimes runnerBob("Bob", 1134);
    runnerBob.addTime(20.0);
    runnerBob.addTime(21.6);
    runnerBob.addTime(19.6);
    runnerBob.print();

    TrialTimes runnerSue("Sue", 1532);
    runnerSue.addTime(18.2);
    runnerSue.addTime(17.6);
    runnerSue.addTime(19.5);
    runnerSue.print();

    ExampleClass a;
    std::cout << "\nExampleClass a;\nThe value of a.getA() = " << a.getA() << std::endl;

    return 0;
}