Menu
CoddyTech

Run the C++ Files

Lesson 1 of 48 in Coddy's C++ for PHP Developers course.

This standalone course transfers your PHP experience to C++17. The PHP interpreter runs a script from its first line each time it is requested or started with php; a C++ program is compiled ahead of time from several files into one executable that starts in main. Run the supplied program, then inspect the declaration in exercise.hpp, its definition in exercise.cpp, and the locked main.cpp entry point. Each later task preserves these public contracts while you implement the editable functions and classes.

challenge icon

Challenge

Easy

Run the supplied files. The function returns a greeting; inspect the header declaration, implementation, and locked entry point.

Implement the declared API in exercise.hpp and exercise.cpp. Both files are editable; preserve the public signatures. The locked main.cpp reads stdin and calls the API directly. It also checks public API behavior independently where stated. Return values rather than printing inside the API. Integer inputs and results fit signed int; text is ASCII unless stated otherwise.

Try it yourself

#include "exercise.hpp"
#include <iostream>
int main(){

std::vector<std::string> rows; std::string line; while(std::getline(std::cin,line)) rows.push_back(line);
std::cout<<greeting()<<"\n";
}

All lessons in C++ for PHP Developers

Practice on your own: Online C++ compiler