Dzielenie kodu - prosba o wskazanie bledow

0

Uzywam CodeBlocks, za pomoca kreatora stworzylem projekt.

Kompilator wywala bledy, wszystkie w pliku Druga.cpp:
Druga.h: No such file or directory|
error: Druga' has not been declared| error: ISO C++ forbids declaration of Druga' with no type|
error: expected constructor, destructor, or type conversion before '::' token|
error: expected ,' or ;' before '::' token|
error: Druga' is not a class or namespace| error: ISO C++ forbids declaration of StworzCos' with no type|

Kody zrodlowe:

 
// Projekcik\include\Pierwsza.h 
#ifndef PIERWSZA_H
#define PIERWSZA_H
#include <iostream>

class Pierwsza
{
    public:
        Pierwsza(int &N, int* &N1);
        virtual ~Pierwsza();

        void WpiszNowe(int &N, int* &N1);
        void Wczytaj(int &N, int* &N1);

    private:
        int N;
        int* N1;

};

#endif // PIERWSZA_H
 
// Projekcik\src\Pierwsza.cpp
#include "Pierwsza.h"
#include <iostream>
#include <conio.h>

Pierwsza::Pierwsza(int &N, int* &N1)
{
    Wczytaj(N, N1);
}

Pierwsza::~Pierwsza()
{
    //dtor
}

Pierwsza::WpiszNowe(int &N, int* &N1)
{
    cout << "WpiszNowe() mowi Podaj liczbe N" << endl;
    cin >> N;

    N1 = new int [N];
    cout << "WpiszNowe() mowi Podaj wartosci N[i]";
    for (int i = 0; i < N; i++)
    {
        cout << "N1[" << i << "]: " << endl;
        cin >> N1[i];
    }
}

Pierwsza::Wczytaj(int &N, int* &N1)
{
    char wybor;
    cout << "Wczytaj() mowi nacisnij 1 by wpisac nowe" << endl;
    cin >> wybor;

    if (wybor == '1') WpiszNowe(N, N1);
    else
    cout << "Zly wybor" << endl;
}
// Projekcik\include\Druga.h
#ifndef DRUGA_H
#define DRUGA_H

class Druga
{
    public:
        Druga();
        virtual ~Druga();
        void StworzCos();
};

#endif // DRUGA_H
// Projekcik\src\Druga.cpp
#include "Druga.h"
#include <iostream>
#include <conio.h>

using namespace std;

Druga::Druga()
{
    //ctor
    cout << "ctor Druga dziala" << endl;
}

Druga::~Druga()
{
    //dtor
}

Druga::StworzCos()
{
    cout << "StworzCos() mowi tworzy cos" << endl;
}
//Projekcik\include\Funkcje.h
#ifndef FUNKCJE_H
#define FUNKCJE_H

void ZrobCosTam();

#endif // FUNKCJE_H
// Projekcik\src\Funkcje.cpp
#include "Funkcje.h"
#include <iostream>
#include <conio.h>

void ZrobCosTam()
{
    cout<<endl<<"ZrobCosTam() mowi BlaBlaBla"<<endl;
}
// Projekcik\main.cpp
#include "Pierwsza.h"
#include "Druga.h"
#include "Funkcje.h"
#include <conio.h>
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;

    int N;
    int* N1;
    Pierwsza ObiektPierwsza(N, N1);

    Druga ObiektDruga();

    ZrobCosTam();

    ObiektDruga.StworzCos();

    system("pause");
    return 0;
    getche()
}

A tutaj dzialajacy kod w jednym pliku:

#include <conio.h>
#include <iostream>
using namespace std;

void ZrobCosTam()
{
    cout<<endl<<"ZrobCosTam() mowi BlaBlaBla"<<endl;
}

class Pierwsza
{
    private:
        int N;
        int* N1;

    public:
        Pierwsza(int &N, int* &N1)
        {
            Wczytaj(N, N1);
        }
        virtual ~Pierwsza(){}

        void WpiszNowe(int &N, int* &N1)
        {
            cout<<"WpiszNowe() mowi Podaj liczbe N"<<endl;
            cin>>N;
            N1 = new int[N];

            cout<<"WpiszNowe() mowi Podaj wartosci N[i]";
            for(int i=0; i<N; i++)
            {
                cout<<"N1["<<i<<"]: "<<endl;
                cin>>N1[i];
            }
        }

        void Wczytaj(int &N, int* &N1)
        {
            char wybor;
            cout<<"Wczytaj() mowi nacisnij 1 by wpisac nowe"<<endl;
            cin>>wybor;   
            if(wybor=='1') WpiszNowe(N, N1);
            else 
            cout<<"Zly wybor"<<endl;
        }
};

class Druga
{
    public:
        Druga()
        {

        }
        ~Druga()
        {

        }

        void StworzCos()
        {
             cout << "StworzCos() mowi tworzy cos" << endl;
        }
};

int main()
{
    int N;
    int* N1;
    Pierwsza ObiektPierwsza(N, N1);

    Druga ObiektDruga;

    ZrobCosTam();

    ObiektDruga.StworzCos();

    system("pause");
    return 0;
    getche();
}
0

przy
#include "jakiś_tam_plik"
ten plik ma się znajdować w tym samym folderze co plik do którego to dołączasz, lub ma być podana ścieżka, np:
// Projekcik\src\Druga.cpp
#include "..\include\Druga.h"

0

Dziekuje za pomoc, dziala very good.
Zmienilem lokalizacje i trzymam wszystko w jednym pliku, zwrocilem uwage czy pliki, ktore zmienily lokalizacje sa zaladowane do projektu.

Pozdrawiam

1 użytkowników online, w tym zalogowanych: 0, gości: 1