hey guys.. this is only my second time doing oop so please help
im getting this problem:
1>2_8.obj : error LNK2019: unresolved external symbol "public: void __thiscall sharhan_1::quad::evaluate(float)" (?evaluate@quad@sharhan_1@@QAEXM@Z) referenced in function _main
1>2_8.obj : error LNK2019: unresolved external symbol "public: void __thiscall sharhan_1::quad::retreive(void)" (?retreive@quad@sharhan_1@@QAEXXZ) referenced in function _main
1>2_8.obj : error LNK2019: unresolved external symbol "public: void __thiscall sharhan_1::quad::change(float,float,float)" (?change@quad@sharhan_1@@QAEXMMM@Z) referenced in function _main
1>2_8.obj : error LNK2019: unresolved external symbol "public: __thiscall sharhan_1::quad::quad(float,float,float,float)" (??0quad@sharhan_1@@QAE@MMMM@Z) referenced in function _main
/*********************************************************
* file name: 2_8.cpp
* date created: 1/18/12
* date of last revision: 1/20/12
* details of the revision: none
* short description: quadratic evaluation
**********************************************************/
#include "quad.h"
#include <iostream>
#include <string>
#include <cstdlib>
#include <iomanip>
usingnamespace std;
usingnamespace sharhan_1;
//function prototypes
void desc();
int main()
{
// Program description
desc();
//initiliazation
char num='h';
float x=0, a=0, b=0, c=0;
//class declaration
quad quad(x,a,b,c);
while (num!='0')
{
cout <<"What would you like to do?"<<endl
<<"1. Change the values of the quadratic formula"<<endl
<<"2. retreive the current values"<<endl
<<"3. evaluate the values at a certain value of x"<<endl
<<"0. To exit"<<endl;
cin >> num;
switch (num)
{
case'1':
cout << "Please enter the A, B and C values respectively \nasn in ax^2+bx+c"<<endl<<endl;
cin >> a >> b >> c;
quad.change(a, b, c);
break;
case'2':
quad.retreive();
break;
case'3':
cout << "Please enter the value of x"<<endl;
cin >> x;
quad.evaluate(x);
break;
case'0':
break;
default:
cout << "ERORR: Please enter a valid number"<<endl;
break;
}
}
return 0;
}
//function implementations
void desc()
{
cout << "This program will accept and evaluate" <<endl
<< "the quadratic formula at a certain value of x\n\n";
}
Have you included then all files necessary in your project? You must have forgotten something there.
Also when publishing code please inform in which file belong every code. I guess the first is your main.cpp, the second is some source file and the third your quad.h file?
Then you extra post is your quad implementation (source code like quad.cpp?)?
Anyway there is a linking error that means you have probably skipped some file in your project
A simple test is to put obviously wrong code in your quad.cpp file. Something like this:
1 2 3 4 5 6 7 8 9 10
//...
quad::quad(float x, float a, float b, float c)
{
xx = x;
aa = a;
bb = b;
cc = c;
foobarbaz; // <- this will make a compiler error
}
Do that and rebuild.
If you don't get a compiler error, you know it's not compiling (and therefore not linking) that cpp file.
Like eypros said, make sure this particular cpp file is added as part of your project. Simply having it open in the IDE is not enough. It must be among the projects files.
oh wow.. that really helped. I realized that I set my implementation file as a .h and then manually changed it. stupid visual studio probably didnt realize that. I just made a new .cpp file and copied everything to it so now it works.. thanks again