Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Brak rozpoznawania klas z innego pliku mimo zainlucdowania go

Ostatnio zmodyfikowano 2017-04-01 15:43
Autor Wiadomość
latajacaryba
Temat założony przez niniejszego użytkownika
Brak rozpoznawania klas z innego pliku mimo zainlucdowania go
» 2017-04-01 02:32:56
Witam. Zobaczcie na screena, to cały problem:

https://zapodaj.net/baf3d0474443a.png.html

Wszystko jest pozaznaczane. Dla osób które będą miały taki problem, a zdjęcie niekoniecznie nadal będzie dostępne:
na screenie jest plik z klasą, w której to klasie jedna z metod przyjmuje obiekt innej klasy. Problem w tym, że ta inna klasa nie jest w tym samym pliku, więc dodałem #include "klasa_b", ale nadal nie działa.

Co poradzić?
P-159654
marcolo2307
» 2017-04-01 11:16:50
Wstaw kod na forum. Kod, nie zdjęcie.
P-159663
latajacaryba
Temat założony przez niniejszego użytkownika
» 2017-04-01 13:27:44
C/C++
// KOD Z PLIKU LISTWA.H
#ifndef LISTWA_H
#define LISTWA_H
#include "Kategoria.h"
#include <Button.h>
#include <string>
#include <vector>
using namespace std;


class Listwa
    : public Button
{
public:
   
    float predkosc;
    bool akcja;
    bool wysunieta;
    float stop;
    Listwa( string napiss, float xx, float yy, string teksture, float stopp );
    bool zasun( float przyspieszenie, vector < Kategoria *> kategorie ); // BLAD TUTAJ
   
protected:
   
private:
};

#endif // LISTWA_H

// KOD Z PLIKU KATEGORIA.H
#ifndef KATEGORIA_H
#define KATEGORIA_H
#include <string>
#include <fstream>
#include "Button.h"
#include "Listwa.h"
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
using namespace std;


class Kategoria
    : public Button
{
public:
   
    Kategoria();
    void ustaw( float ilex, float iley = 0 );
   
protected:
   
private:
   
    string fiszki_kategorii;
   
};

#endif // KATEGORIA_H
LOG

||=== Build: Debug in Sfml textbox (compiler: GNU GCC Compiler) ===|
include\Listwa.h|19|error: 'Kategoria' was not declared in this scope|
include\Listwa.h|19|error: template argument 1 is invalid|
include\Listwa.h|19|error: template argument 2 is invalid|
include\Listwa.h|19|error: 'Kategoria' was not declared in this scope|
include\Listwa.h|19|error: template argument 1 is invalid|
include\Listwa.h|19|error: template argument 2 is invalid|
include\Listwa.h|19|error: 'Kategoria' was not declared in this scope|
include\Listwa.h|19|error: template argument 1 is invalid|
include\Listwa.h|19|error: template argument 2 is invalid|
include\Listwa.h|19|error: 'Kategoria' was not declared in this scope|
include\Listwa.h|19|error: template argument 1 is invalid|
include\Listwa.h|19|error: template argument 2 is invalid|
include\Listwa.h|19|error: 'Kategoria' was not declared in this scope|
include\Listwa.h|19|error: template argument 1 is invalid|
include\Listwa.h|19|error: template argument 2 is invalid|
include\Listwa.h|19|error: 'vector' is not a type|
include\Listwa.h|19|error: expected ',' or '...' before '<' token|
||=== Build failed: 17 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|

19 linia to wlasnie linia deklaracji metody "zasun"


Moge na życzenie wstawić definicję problematycznej metody "zasun", ale nie wydaje mi sie to potrzebne, gdyż błąd wyskakuje przy deklaracji
P-159668
michal11
» 2017-04-01 13:33:05
Masz cykliczna zależność, Listwa includuje Kategorię a Kategoria Listwę, pomijając to, że w deklaracji Kategorii nigdzie nie wykorzystujesz listwy to możesz to załatwić deklaracją zapowiadającą albo klasą proxy.
P-159670
latajacaryba
Temat założony przez niniejszego użytkownika
» 2017-04-01 15:43:14
Otóż to, dzięki :)
wiem, że niepotrzebny include, ale robiłem te wsyzstkie klasy (mam ich 4) w jednym pliku - main.cpp. Kiedy okazało się, że jest tego za dużo to porozdzielałem to na osobne pliki .h i .cpp ale nie chciało mi sie analizować metod żeby sprawdzić czy zasami nie używam tam obiektow innych klas więc poincludowałem te, które jak mi się zdawało będą potrzbene
P-159677
« 1 »
  Strona 1 z 1