Simple c++ material for starters

Can someone post a simple snippet for generating a material that has a texture connected its base colour.

Everything must be done in c++ code. Possible to do?

And generally speaking, how to write a material in code just by looking at the equivalent blueprint?

An easier route that might satisfy your needs is to instead create a base material with a texture parameter and assign a Material Instance with that parameter set wherever you want a new instance of your class.
The code will look something like:

auto MID = SomeStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0);

If you really want to create a Material (which requires the Editor, and so can’t be done in a shipping game), take a look at UnFbx::FFbxImporter::CreateUnrealMaterial in FbxMaterialImport.cpp. This creates the Material and calls UnFbx::FFbxImporter::CreateAndLinkExpressionForMaterialProperty for each property that it is trying to set.