I havent been programming for a while so i forgot how to use refrencing :P i usually write up example code for stuff like that so i can look at it but i dont seem to have one for refrencing :S so here is my code and im only refrencing one thing so please help :P
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include <iostream>
#include <ctime>
#include <random>
#include <string>
#include <fstream>
using namespace std;
void MAINPROGRAM(int &newComp);
void MENU();
int main()
{
int money = 0;
string item[7];
string BNAME; //Business name
string PNAME; //Player name
string choice;
bool newComp = false; //New
ofstream file("FILE.txt");
cout << "New" << endl;
cout << "Load" << endl;
cout << "\n";
getline(cin, choice);
if(choice == "New" || choice == "new")
{
cout << "please enter your business name." << endl;
getline(cin, BNAME);
cout << "\n";
cout << "Now please enter your name." << endl;
getline(cin, PNAME);
cout << "\n";
cout << "Now you will be asked to enter a name for several products you" << endl;
cout << "wish to sell in your shop, enter the name and press enter\n" << endl;
cout << "Item 1: "; getline(cin, item[0]);
cout << "" << endl;
cout << "Item 2: "; getline(cin, item[1]);
cout << "" << endl;
cout << "Item 3: "; getline(cin, item[2]);
cout << "" << endl;
cout << "Item 4: "; getline(cin, item[3]);
cout << "" << endl;
cout << "Item 5: "; getline(cin, item[4]);
cout << "" << endl;
cout << "Item 6: "; getline(cin, item[5]);
cout << "" << endl;
cout << "Item 7: "; getline(cin, item[6]);
cout << "" << endl;
newComp = true;
//Below we will save all the info the user inputted
//into a text document
file << item[0] << endl;
file << item[1] << endl;
file << item[2] << endl;
file << item[3] << endl;
file << item[4] << endl;
file << item[5] << endl;
file << item[6] << endl;
file << "\n" << endl;
file << BNAME << endl;
file << PNAME << endl;
file << "\n";
file << newComp << endl;
cin.get();
MAINPROGRAM(newComp);
}
if(choice == "Load" || choice == "load")
{
MAINPROGRAM(newComp);
}
}
void MAINPROGRAM(newComp)
{
ofstream file("FILE.txt");
file >> newComp;
if(newComp == true)
{
cout << "test" << endl;
}
else{"Error Code: 1"}
}
void MENU()
{
}
|
ERRORS:
||=== test, Debug ===|
C:\Users\Chay Hawk\Desktop\test\main.cpp||In function 'int main()':|
C:\Users\Chay Hawk\Desktop\test\main.cpp|82|error: invalid initialization of reference of type 'int&' from expression of type 'bool'|
C:\Users\Chay Hawk\Desktop\test\main.cpp|9|error: in passing argument 1 of 'void MAINPROGRAM(int&)'|
C:\Users\Chay Hawk\Desktop\test\main.cpp|87|error: invalid initialization of reference of type 'int&' from expression of type 'bool'|
C:\Users\Chay Hawk\Desktop\test\main.cpp|9|error: in passing argument 1 of 'void MAINPROGRAM(int&)'|
C:\Users\Chay Hawk\Desktop\test\main.cpp|14|warning: unused variable 'money'|
C:\Users\Chay Hawk\Desktop\test\main.cpp|91|error: variable or field 'MAINPROGRAM' declared void|
C:\Users\Chay Hawk\Desktop\test\main.cpp|91|error: 'newComp' was not declared in this scope|
||=== Build finished: 6 errors, 1 warnings ===|