Witam mam problem z konwersja w klasach. Robię tak jak jest napisane w książce, ale wywala błędy:
Kon.h
#pragma once
#include <iostream>
class Name;
class Kon
{
private:
float x;
float y;
public:
void zmien(float X, float Y)
{
x = X;
y= Y;
}
void wypisz(Kon X)
{
std::cout<<X.x;
}
Kon(Name X)
{
x = X.c;
}
Kon(void);
~Kon(void);
};
Name.h
#pragma once
#include "Kon.h"
class Name
{
private:
float c;
public:
void wypisz(Name X)
{
std::cout<<X.c;
}
void zmienC(float g)
{
c=g;
}
friend Kon::Kon(Name);
Name();
~Name(void);
};
Main.cpp
#include "Name.h"
int main()
{
Kon X;
Name W;
W.zmienC(5);
X.wypisz(W);
getchar();
}
Błędy
1>kon.h(21): error C2027: use of undefined type 'Name'
kon.h(3) : see declaration of 'Name'
kon.h(21): error C2228: left of '.c' must have class/struct/union
Kon.cpp
error C2027: use of undefined type 'Name'
kon.h(3) : see declaration of 'Name'
kon.h(21): error C2228: left of '.c' must have class/struct/union
Shalom