Oct 14, 2013 at 2:13pm UTC
Hello, I have a relly serious problem.
I'm trying to read my txt file
Tr1 6 1.5 -5.5 5 -1.4 8.5 -5.2
Aps3 3 5.5 -5.5 10
Kt4 8 -3.5 -0.5 -3.5 5.4 2.4 5.4 2.4 -0.5
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
void Read(FiguresCon & fgk, const char CD[CMaxx], int & n){
double x, y, s;
string name;
string appav, trpav, ktpav;
Figura f;
ifstream fd(CD);
while (!fd.eof()){
fd >> name >> n;
f.Check(n);/////////////////////////////PROBLEM/////
f.SetName(name);
f.SetN(n);
if (n==3){
fd >> x >> y >> s;
f.SetAps(0, x, y, s);
}else
for (int i=0; i<n/2; i++){
fd >> x >> y;
f.SetKord(i, x, y);
}
fgk.Set(f);
}
fd.close();
}
And here is my Figure.h file
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
#include <string>
using namespace std;
#pragma once
class Figure{
public :
static const int CMax = 100;
private :
string name;
double xkoordinate[CMax];
double ykoordinate[CMax];
double spindulys;
int n;
public :
// konstruktorius
Figura(): pavadinimas("" ), n(0){}
Figura(string pavadinimas, int n):
pavadinimas(pavadinimas), spindulys(spindulys), n(n) {}
Figura(string pavadinimas, double spindulys, int n):
pavadinimas(pavadinimas), spindulys(0.0), n(0){}
//
void SetPav(string pa) {pavadinimas = pa;}
void SetN(int nn) { n = nn;} // negalima rasyti n=n!, nes kompiliatorius nezino kam priskirti
void SetAp(int i, double x, double y, double s) {xkoordinate[i] = x; ykoordinate[i] = y; spindulys = s;}
void SetKord(int i, double x, double y) {xkoordinate[i] = x; ykoordinate[i] = y;}
string Print();
string Check(int n);
};
and here's my Figure.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
string Check (int n) {
string pavadinimasfig;
if (n==6){
pavadinimasfig = " Trikampis" ;
return pavadinimasfig;
}else if (n == 8){
pavadinimasfig = " Keturkampis" ;
return pavadinimasfig;
}else if (n==3){
pavadinimasfig = "Apskritimas" ;
}else
pavadinimasfig = "Nezinoma figura" ;
return pavadinimasfig;
}
And my program doesnw work and I get this error
error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Figura::Tikrinimas(int)" (?Tikrinimas@Figura@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function "void __cdecl Ivesti(class FiguruKoteineris &,char const * const,int &)" (?Ivesti@@YAXAAVFiguruKoteineris@@QBDAAH@Z)
What is wrong?
Last edited on Oct 14, 2013 at 2:21pm UTC
Oct 14, 2013 at 2:18pm UTC
you're reading into an int
variable, but the values are not. Use float
or double
instead
Oct 14, 2013 at 2:21pm UTC
No I'm reading n(6, 3, 8) into int variable. :( An thats correct something wrong with string Check :( Or something is wrong with calling that function and I can't find the mistake
Last edited on Oct 14, 2013 at 2:24pm UTC
Oct 14, 2013 at 2:26pm UTC
but the linker error occurs in Ivesti
. It says that Tikrinimas
is not implemented
Oct 14, 2013 at 2:31pm UTC
Sorry, I dont understand. What,s wrong I dont understand wher's the mistake How I need to refer to Tikrinimas or Check function in my Read function then?
Oct 14, 2013 at 2:41pm UTC
ok let me guess:
Tikrinimas
is Check
and
Ivesti
is Read
Why are the errors different from your code?
Anyway
string Check (int n) {
has to be
string Figure:: Check (int n) {
now is it Figure
or Figura
? You should stick to one