[Linker error] undefined reference... pliki .h... dev-c++

S

s_4

Witam!
Mam maly problem... to chyba juz wszyscy wiedza... :)
do rzeczy:

1. zrobilem maly projekt i wywala mi takie bledy jak w tytule (tylko
takie)
2. kompilujac kazdy plik z osobna nie ma bledow, ale kompilujac caly
projekt to wystepuja powyzsze bledy
3. specjanie na potrzeby tego postu mocno okroilem moj projekt i nadla
wywala ten sam blad tylko w trzech miejscach, a nie w stu piedziesieciu
pieciu, wiec chyba bedzie latwiej namierzyc blad

zamieszam kod:
--------------------------- Plik main.cpp ----------------------------
#include <iostream>
#include <cstdlib>
#include "Samochod.h"
#include "ListaSamochodow.h"

using namespace std;

int main(int argc, char *argv[])
{
ListaSamochodow::wyswietl_liste_S();
cout << "Lista Samochodow to: \n";
cout << ListaSamochodow::lista_samochodow.nazwa << "\n";
Samochod::wypozycz_S();
system("PAUSE");
return EXIT_SUCCESS;
}

---------------------------------- Plik Samochod.cpp
-------------------------------
#include <iostream>
#include <string.h>
#include "Samochod.h"
#include "ListaSamochodow.h"

using namespace std;

Samochod::Samochod()
{
}
Samochod::~Samochod()
{
}

void Samochod::wypozycz_S()
{
cout << "lista samochodow to " <<
ListaSamochodow::lista_samochodow.nazwa << "udalo sie";
}

--------------------------------- Plik Samochod.h
--------------------------------------
#ifndef SAMOCHOD_H
#define SAMOCHOD_H
#include <iostream>
#include <string.h>

class Samochod {
public:
Samochod();
~Samochod();
int cena;
string rodzaj;
string nazwa;
string stan;
static void wypozycz_S();
};

#endif //SAMOCHOD_H

------------------------ Plik ListaSamochodow.cpp
------------------------------------------
#include <iostream>
#include <string.h>
#include "ListaSamochodow.h"
#include "Samochod.h"

ListaSamochodow::ListaSamochodow()
{
}
ListaSamochodow::~ListaSamochodow()
{
}

void ListaSamochodow::wyswietl_liste_S()
{
ListaSamochodow::lista_samochodow.nazwa = "Audi";
}

------------------------- Plik ListaSamochodow.h
-----------------------------------------
#ifndef LISTASAMOCHODOW_H
#define LISTASAMOCHODOW_H
#include <iostream>
#include <string.h>
#include "Samochod.h"

class ListaSamochodow : public Samochod {
public:
ListaSamochodow();
~ListaSamochodow();
static void wyswietl_liste_S();
static Samochod lista_samochodow;
};

#endif //_LISTA SAMOCHODOW_H
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

Uzywam kompilatora Dev-C++ w wersji 4.9.9.2
Ten maly projek powinien wyswietlac zmienna skladowa "nazwa" obieku
"lista_samochodow"
Klasa ListaSamochodow dziedziczy z klasy Samochod.
Co mam zrobic aby takie bledy mi nie wychodzily?
Czym to moze byc spowodowane?

Prosze Was drodzy internauci o pomoc...
Z gory dziekuje.
Marcin Bojarczuk
 
S

s_4

Sorry I send post to wrong language group...
my English is weak... :-(

I have a problem during compilation

[Linker error] undefined reference to
`ListaSamochodow::lista_samochodow'
Above is a code..
The program should write on screen (windows console) value of member
variable - object lista_samochodow.
 
S

s_4

I want to add that each file was copmpiled and there was no mistakes...
but if I compile all project, a compilator show me a [linker error]
undefined reference (in three places)
 
P

Peter Jansson

I want to add that each file was copmpiled and there was no mistakes...
but if I compile all project, a compilator show me a [linker error]
undefined reference (in three places)

Hello,

Could you show us the linker error (in english)?
Perhaps a library was not included in the correct order while linking.

Regards,
Peter Jansson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top