C++ Kompilacja dwóch plików w IDE Code::Blocks

0

Witam mam dwa takie pliki

//vect.h
#ifndef VECTOR_H_
#define VECTOR_H_
#include <iostream>
namespace VECTOR
{
    class Vector
        {
            private:
                double x;   //wartos skladowej poziomej
                double y;   //wartos skladowej pionowej
                double mag; //dlugosc wektora
                double ang; //kierunek wektora
                char mode;  //'r'=tryb prostokatny, 'p'=tryb biegunowy
                //prywatne metody ustawiajace skladowe
                void set_mag();
                void set_ang();
                void set_x();
                void set_y();
            public:
                Vector();
                Vector(double n1, double n2, char form = 'r');
                void set(double n1, double n2, char form = 'r');
                ~Vector();
                double xval() const (return x);
                double yval() const (return y);
                double magval() const (return mag);
                double angval() const (return ang);
                void polar_mode();
                void rect_mode();
                //metody przeciazajace operatory
                Vector operator+(const Vector &b) const;
                Vector operator-(const Vector &b) const;
                Vector operator-() const;
                //funkcje zaprzyjaznione
                friend Vector operator*(double n, const Vector &a);
                friend std::ostream & operator<<(std::ostream &os, const Vector & v);
        };
}   //koniec przestrzeni nazw VECTOR

#endif

//vect.cpp
#include <cmath>
#include "vect.h"

using std::sin;
using std::cos;
using std::atan2;
using std::cout;

namespace VECTOR
{
    const double Rad_to_deg = 57.2957795130823;
    //metody prywatne
    //oblicza dlugosc wektora ze skladowych x i y
    void Vector::set_mag()
    {
        mag = sqrt(x*x+y*y);
    }

    void Vector::set_ang()
    {
        if (x == 0.0 && y == 0.0)
            ang = 0.0;
        else
            ang = atan2(y, x);
    }

    //oblicza skladowa x ze wspolrzednych biegunowych
    void Vector::set_x()
    {
        x = mag * cos(ang);
    }

    //oblicza skladowa y ze wspolrzednych biegunowych
    void Vector::set_y()
    {
        y = mag * sin(ang);
    }

    //metody publiczne
    Vector::Vector()    //konstruktor domyslny
    {
        x = y = mag = ang = 0.0;
        mode = 'r';
    }
}

W drugim pliku jeszcze nie wszystkie metody są napisane jednak już widzę że drugi plik nie korzysta z pierwszego, Code::Blocks wywala masę błędów odnośnie kompilacji jednak wszystkie są związane z brakiem odczytywania pierwszego pliku. Mam utworzony jeden katalog w którym są podkatalogi: bin, include(znajduje się tu plik vect.h), obj, src(znajduje się tu plik vect.cpp). Pliki tworzyłem przy pomocy File ->New -> Class... utworzyły mi się wyżej wymienione foldery. Bardzo bym prosił o pomoc gdyż po raz pierwszy pisze program podzielony na kilka plików i nie wiem co teraz zrobić

0

@odswiezam

0

Pokaż treści błędów.

0

error: vect.h: No such file or directory|
error: 'std::cout' has not been declared|
error: 'Vector' has not been declared|
In function 'void VECTOR::set_mag()':|
error: 'mag' was not declared in this scope|
error: 'x' was not declared in this scope|
error: 'y' was not declared in this scope|
error: 'Vector' has not been declared|
In function 'void VECTOR::set_ang()':|
error: 'x' was not declared in this scope|
error: 'y' was not declared in this scope|
error: 'ang' was not declared in this scope|
error: 'ang' was not declared in this scope|
error: 'Vector' has not been declared|
In function 'void VECTOR::set_x()':|
error: 'x' was not declared in this scope|
error: 'mag' was not declared in this scope|
error: 'ang' was not declared in this scope|
error: 'Vector' has not been declared|
In function 'void VECTOR::set_y()':|
error: 'y' was not declared in this scope|
error: 'mag' was not declared in this scope|
error: 'ang' was not declared in this scope|
error: 'Vector' has not been declared|
error: ISO C++ forbids declaration of 'Vector' with no type|
In function 'int VECTOR::Vector()':|
error: 'x' was not declared in this scope|
error: 'y' was not declared in this scope|
error: 'mag' was not declared in this scope|
error: 'ang' was not declared in this scope|
error: 'mode' was not declared in this scope|
warning: no return statement in function returning non-void|
|=== Build finished: 26 errors, 1 warnings ===|

Dodam że błędy występują podczas kompilacji pliku vect.cpp, plik vect.h kompiluje się bez błędów

0

Plik ,h wcale się nie kompiluję. Bierzesz się za klasy a nie wiesz pomiędzy czym umieszcza się ciało funkcji/metody ?

0
//vect.h
#ifndef VECTOR_H_
#define VECTOR_H_
#include <iostream>
namespace VECTOR

i szczerze mówiąc nie wiem co chcesz tu osiągnąć.. zwłaszcza, że plik się nazywa vect

0

i zobacz jeszcze czy pliki są w tym samym folderze.

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