J
Joey Bork Dugan
I'm a beginner C++ programmer and I'm having an issue with a Linker
Error. I keep getting the following:
[Linker error] undefined reference to `pcheck(int, int)'
ld returned 1 exit status
I've been staring at it for HOURS and I can't figure it out! Help
please?
Below is my code:
#include <iostream> //to use input and output
#include <iomanip> //to use fixed, set precision
#include <fstream> //to input/output files
using namespace std; //to use standard c++ functions
int batch9[20][4]={0};
long double volumes[20]={0};
double Vhats=(3.14*(10*10)*10),Vboots=(8*10*18),Vcanes=(.5*7*7*12);
long double TVhats,TVboots,TVcanes,x;
int set;
bool fcheck, fits[20];
bool filecheck();
bool fitcheck(long double);
bool pcheck(int,int);
int main(){ //beginning program
cout<<"Integrated Project Console"<<endl;
fcheck=filecheck();
if (fcheck==false){ //Tests to see if file
was open
cout<<"File not opened!"<<endl<<endl; //Returned if file is
not opened
system("pause");
return 0;
}//end if
else {
cout<<"File opened successfully!"<<endl<<endl; //Returned if file
is opened
}//end else
Vhats=Vhats+(Vhats*.12);
Vboots+=(Vboots*.12);
Vcanes+=(Vcanes*.12);
ifstream infile;
infile.open("Batch_09.txt");
for (int a=0;a<20;a++){
for (int b=0;b<4;b++){
infile>>batch9[a]; //Creates 2D Matrix from
the file
}//end loop b
}//end loop a
cout<<fixed<<setprecision(2);
cout<<setw(10)<<"Set #"<<setw(6)<<"Hats"<<setw(6)<<"Boots";
cout<<setw(14)<<"Shillelaghs"<<endl;
for (int c=0;c<20;c++){
for (int d=0;d<4;d++){
cout<<setw(6)<<batch9[c][d]<<" ";
}//end loop d
cout<<endl;
}//end loop c
for (set=0;set<20;set++){
if (pcheck(set,batch9[20][4])==false){
volumes[set]=3000000;
}//end if
else {
TVhats = batch9[set][1]*Vhats;
TVboots = batch9[set][2]*Vboots;
TVcanes = batch9[set][3]*Vcanes;
volumes[set]=TVhats+TVboots+TVcanes;
}//end else
}//end for
for (set=0;set<20;set++){
x=volumes[set];
if (fitcheck(x)==true){
fits[set]=true;
}
else {
fits[set]=false;
}
}
for (int a=0;a<20;a++){
if (fits[a]==true){
cout<<"Set "<<a+1<<" fits"<<endl;
}
else if (fits[a]==false){
cout<<"Set "<<a+1<<" does not fit"<<endl;
}
}
cout<<endl;
system("pause");
return 0;
}//end main()
//
================================PERCENTCHECK==================================
bool pcheck(int set,int batch9[20][4]){
int x=batch9[set][1];
int y=batch9[set][2];
int z=batch9[set][3];
int items=x+y+z;
int Pitems = items/10;
if (x<Pitems||y<Pitems||z<Pitems){
return false;
}//end if
else{
return true;
}//end else
}//end percentcheck()
//
================================FITCHECK======================================
bool fitcheck(long double x){
long double container=(1320*(12*12*12));
if (x<=container){
return true;
}//end if
else {
return false;
}//end else
}//end fitcheck()
//
================================FILECHECK=====================================
bool filecheck(){
ifstream infile;
infile.open("Batch_09.txt"); //Opens File
if (!infile){ //Tests to see if file was
open
return false;
}//end if
else {
return true;
}//end else
}//end filecheck()
Error. I keep getting the following:
[Linker error] undefined reference to `pcheck(int, int)'
ld returned 1 exit status
I've been staring at it for HOURS and I can't figure it out! Help
please?
Below is my code:
#include <iostream> //to use input and output
#include <iomanip> //to use fixed, set precision
#include <fstream> //to input/output files
using namespace std; //to use standard c++ functions
int batch9[20][4]={0};
long double volumes[20]={0};
double Vhats=(3.14*(10*10)*10),Vboots=(8*10*18),Vcanes=(.5*7*7*12);
long double TVhats,TVboots,TVcanes,x;
int set;
bool fcheck, fits[20];
bool filecheck();
bool fitcheck(long double);
bool pcheck(int,int);
int main(){ //beginning program
cout<<"Integrated Project Console"<<endl;
fcheck=filecheck();
if (fcheck==false){ //Tests to see if file
was open
cout<<"File not opened!"<<endl<<endl; //Returned if file is
not opened
system("pause");
return 0;
}//end if
else {
cout<<"File opened successfully!"<<endl<<endl; //Returned if file
is opened
}//end else
Vhats=Vhats+(Vhats*.12);
Vboots+=(Vboots*.12);
Vcanes+=(Vcanes*.12);
ifstream infile;
infile.open("Batch_09.txt");
for (int a=0;a<20;a++){
for (int b=0;b<4;b++){
infile>>batch9[a]; //Creates 2D Matrix from
the file
}//end loop b
}//end loop a
cout<<fixed<<setprecision(2);
cout<<setw(10)<<"Set #"<<setw(6)<<"Hats"<<setw(6)<<"Boots";
cout<<setw(14)<<"Shillelaghs"<<endl;
for (int c=0;c<20;c++){
for (int d=0;d<4;d++){
cout<<setw(6)<<batch9[c][d]<<" ";
}//end loop d
cout<<endl;
}//end loop c
for (set=0;set<20;set++){
if (pcheck(set,batch9[20][4])==false){
volumes[set]=3000000;
}//end if
else {
TVhats = batch9[set][1]*Vhats;
TVboots = batch9[set][2]*Vboots;
TVcanes = batch9[set][3]*Vcanes;
volumes[set]=TVhats+TVboots+TVcanes;
}//end else
}//end for
for (set=0;set<20;set++){
x=volumes[set];
if (fitcheck(x)==true){
fits[set]=true;
}
else {
fits[set]=false;
}
}
for (int a=0;a<20;a++){
if (fits[a]==true){
cout<<"Set "<<a+1<<" fits"<<endl;
}
else if (fits[a]==false){
cout<<"Set "<<a+1<<" does not fit"<<endl;
}
}
cout<<endl;
system("pause");
return 0;
}//end main()
//
================================PERCENTCHECK==================================
bool pcheck(int set,int batch9[20][4]){
int x=batch9[set][1];
int y=batch9[set][2];
int z=batch9[set][3];
int items=x+y+z;
int Pitems = items/10;
if (x<Pitems||y<Pitems||z<Pitems){
return false;
}//end if
else{
return true;
}//end else
}//end percentcheck()
//
================================FITCHECK======================================
bool fitcheck(long double x){
long double container=(1320*(12*12*12));
if (x<=container){
return true;
}//end if
else {
return false;
}//end else
}//end fitcheck()
//
================================FILECHECK=====================================
bool filecheck(){
ifstream infile;
infile.open("Batch_09.txt"); //Opens File
if (!infile){ //Tests to see if file was
open
return false;
}//end if
else {
return true;
}//end else
}//end filecheck()