I am a beginner in C++ coding and need some help. This first part is given and I will post what I wrote after. I have the complete program listed below and keep getting the following fatal error: 1>------ Build started: Project: Lab 2, Configuration: Debug Win32 ------
1> Lab 2.cpp
1>c:\users\documents\visual studio 2010\projects\lab 2\lab 2\lab 2.cpp(19): fatal error C1083: Cannot open include file: 'Resistor.h': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here is my code and any help would be greatly appreciated!
#include "Resistor.h"
#include <iostream>
#include <iomanip>
#include <Windows.h>
#include <math.h>
#include <string>
using namespace std;
//EIA Standard array element sizes per tolerance class
const int E12 = 12;
const int E24 = 24;
const int E48 = 48;
const int E96 = 96;
// In this file, all the class member functions that are
// declared in the "Resistor.h" file are defined.
#include "Resistor.h"
#include <iostream>
#include <iomanip>
#include <string.h>
#include <Windows.h>
using namespace std;
//This functions retrieves the nominal resistance value from the user.
double CResistor::getNominal(bool fnDisplay)
{
fnDisplay = true;
if (fnDisplay != false)
{
cout << " The 'getNominal' function has been called" << endl;
}
return nominalRes;
}
//This function retrieves the nominal tolerance from the user and display's
//a test message that states the function has been called if the correct boolean
//value has been set.
double CResistor::getTolerance(bool fnDisplay)
{
fnDisplay = true;
if (fnDisplay != false)
{
cout << " The 'getTolerance()' function has been called" << endl;
}
return nominalTol;
}
//This function retrieves the resistor name from the user.
string CResistor::getResName(bool fnDisplay)
{
fnDisplay = true;
if (fnDisplay != false)
{
cout << " The 'getResName()' function has been called" << endl;
}
return (resistorName);
}
//This function defines the Constructor. The Constructor has 4 defualt parameters that will
//initialize the class member attributes nominalRes, nominalTol and resistorName to a default
//value.
CResistor::CResistor(double R,double T,string rN,bool fnDisplay)
{
fnDisplay = true;
if(fnDisplay != false)
{
cout << "The Constructor is called" << endl;
cout << endl;
if(0.0 < R)
{
nominalRes = R;
}
else
{
nominalRes = 0.0;
}
if(.00 < T)
{
nominalTol = T;
}
else
{
nominalTol = .00;
}
resistorName = rN;
}
}
//This function will reset the class member attribute "nominalTol"
//to the user defined tolerance value.
void CResistor::setTolerance(double Tol,bool fnDisplay)
{
fnDisplay = true;
if(fnDisplay != false)
{
cout <<"The setTolerance function was called" << endl;
}
nominalTol = Tol;
}
Is there a file named Resistor.h in the same location as the file that you posted?
It looks to me like you might be using visual studio, is that correct?
Yes I am using visual basic 2010 and that is my whole file split into 2 sections, because it would not let me post it all at once. I wrote the 2 files on the bottom and I was given the big file on the top.
No. That is what I got lost on....That is what I was told the resistor class would be or pull up. Like I said before I am new and don't completely understand.
I am have done a lot of work on this and would appreciate a small amount of help. I am now down to just one error - 1>Lab 2.cpp(39): error C2059: syntax error : ';'. I will list all the code I have now to see if anyone can see what I am missing. These are my .h and .cpp files for the class I had to write:
Your professor purposefully give you a program with two main functions????
That is unusual.
I made a post above about the same time that you posted your main.cpp
There I fixed the code and no the resistor.cpp is generated when you make a resistor.h file. Or are you taking about the int_tmain line? If so, that is created by Visual Basic 2010 when I open a new console cpp project.