I am trying to make a program for myself to keep a database of the ingredients and chemicals used in the drinks and foods I drink. I am kinda of new to C++, but I am not an absolute beginner, so I am somewhere between beginner and mediocre.
Anyways
I created a class called "Drink", I want to make the objects within the class the different drinks I drink and their info. SO FAR I think I have it down, but what I need to learn is how to make this work with different files? I want to make a program that uses different files but also saves on the compilation time, basically a method where if I edit one item it won't cause a 15 min compilation period to change everything, which is why, even though this works fine on one program it's not really what I want.
What I've learned so far is : 1. need header files. 2. need a(or many) different cpp files. 3. need to connect them.
If you can and will help, I would like a detailed explanation please, if you can add things like better methods than my current method, shortcuts or anything of that sort I would really appreciate it. Also, I know how to select and answer and up-vote.Thanks in advance.
#include <iostream> #include <string> using namespace std ; class Drink{public: void output_information() { cout << "Details: "<< info << endl ; } string info ;};int main(){ string input ; Drink Arizona_Green_Tea ; Arizona_Green_Tea.info = "\n Premium Brewed Green Tea \n Filtered Water \n High- Fructose Corn Syrup \n Honey \n Citric Acid \n Natural Flavors \n Ginseng Extract \n Ascorbic Acid " ; Drink Honest_Ade_Green_Tea ; Honest_Ade_Green_Tea.info = "\n FILTERED WATER \n ORGANIC CANE SUGAR \n FAIR TRADE ORGANIC GREEN TEA LEAVES \n ORGANIC HONEY \n NATURAL FLAVOR \n ASCORBIC ACID (VITAMIN C) \n CITRIC ACID" ; Drink Vitamin_Water_power_c ; Vitamin_Water_power_c.info = "reverse osmosis water \n crystalline \n fructose and cane sugar (sweeteners) \n less than 0.5% of: \n vitamin C (ascorbic acid), citric \n acid, natural flavors, dragonfruit \n extract, vegetable juice (color), \n magnesium lactate and calcium \n lactate and potassium phosphate \n (electrolyte sources), taurine, \n vitamin B5 (calcium pantothenate), \n zinc gluconate, vitamin B6 \n (pyridoxine hydrochloride)\n vitamin B12 \n chromium polynicotinate" ;cout << "Search Database: " ;getline(cin , input) ;cout << endl ;if(input == "Arizona Green Tea" || input == "arizona green tea" || input == "ARIZONA GREEN TEA") { Arizona_Green_Tea.output_information() ; }if(input == "Honest Ade Green Tea") { Honest_Ade_Green_Tea.output_information() ; }if(input == "Vitamin Water Power" || input == "vitamin water power-c" || input =="VITAMIN WATER POWER C" || input == "Vitamin Water Power C" || input =="vitamin water red" || input == "Vitamin Water Red" ) { Vitamin_Water_power_c.output_information() ; } return 0 ; }