c++ - error LNK2019: unresolved external symbol referenced in function _main -


i know problem there before, didn't find solution me. - i'm getting error in visual studio 2010.:

error lnk2001: unresolved external symbol "class czas __cdecl data(void)" (?data@@ya?avczas@@xz)

i have main() function, , have console set in propetites.

and code:

czas.h

#ifndef czas_h #define czas_h class czas{ private:     int dzien;     int miesiac;     int rok; public:     int dzien() const;     int miesiac() const;     int rok() const;     czas(int dl, int m, int r);     void ustaw (int d, int m, int r);     void wypisz() const;     void wpisz();     void koryguj();     int porownaj (const czas& wzor) const; }; #endif 

czas.cpp

#include "czas.h" #include <iostream> using namespace std;      int dzien;     int miesiac;     int rok;     int czas::dzien() const     {         return dzien;     }     int czas::miesiac() const     {         return miesiac;     }     int czas::rok() const     {         return rok;     }     czas::czas(int d=1, int m=1, int r=1970)     {         dzien = d;         miesiac = m;         rok = r;         koryguj();     }     void czas::ustaw (int d, int m, int r)     {         dzien = d;         miesiac = m;         rok = r;     }     void czas::wypisz() const     {         //wypisujemy dzien;         if (dzien<10)             cout<<"0"<<dzien<<".";         else             cout<<dzien<<".";         //wypisujemy miesiac         if (miesiac<10)             cout<<"0"<<miesiac<<".";         else             cout<<miesiac<<".";         //wypisujemy rok             cout<<rok;     }     void czas::wpisz()     {         cin>>dzien;         cin>>miesiac;         cin>>rok;         koryguj();     }     void czas::koryguj()     {         if (dzien>31)             dzien = 31;         if (dzien<1)             dzien = 1;          if (miesiac>12)             miesiac = 12;         if (miesiac<1)             miesiac = 1;      }     int czas::porownaj (const czas& wzor) const     {         if (dzien == wzor.dzien() && miesiac == wzor.miesiac() && rok == wzor.rok())             return 1;         else              return 0;     } 

and main.cpp

#include "czas.h" #include <iostream>  using namespace std; int main(int argc, char **argv) {     int flaga=1, flaga2=0;     czas data();     cout<<"1 - wpisz date\n2 - wypisz date\n3 - porownaj\nx - wyjscie";     while (flaga == 1)     {         fflush(stdin);         switch (getchar())         {         case '1':             {                 data().wpisz();                 flaga2=1;                 break;             }         case '2':             {                 if (flaga2=0)                     cout<<"trzeba najpierw wpisac date!";                 else         //          data().wypisz();                 break;             }         case '3':             {                 if (flaga2=0)                     cout<<"trzeba najpierw wpisac date!";                 else                 //  czas().porownaj                 break;             }         case 'x':             {                 flaga=0;                 break;             }         default:             {                 cout<<"klawisz nieobslugiwany";                 break;             }         }     }     return 0; } 

what have wrong here?

czas data(); 

this declares function called data takes no arguments , returns czas. think want default construct czas object so:

czas data; 

which means should remove parentheses after data in line, since not function:

data().wpisz(); //  ^^ remove 

in addition, you'll need move default arguments constructor header file:

    czas(int dl = 1, int m = 1, int r = 1970); 

the default arguments need visible code includes header, know can call without arguments.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -