友元类成员问题
//Bottle.h
#pragma once
#include"Cartorn.h"
class CBottle
{
private:
double m_Length;
double m_Diameter;
public:
CBottle(double Length,double Diameter)
{
m_Length=Length;
m_Diameter=Diameter;
}
friend CCartorn::CCartorn(const CBottle& abottle); //这里出错
};
//Cartorn.h
#pragma once
#include"Bottle.h"
#include<iostream>
using namespace std;
class CCartorn
{
private:
double m_Length;
double m_Height;
double m_Width;
public:
CCartorn(const CBottle& abottle)
{
m_Length=abottle.m_Length;
m_Height=abottle.m_Diameter*3;
m_Width=abottle.m_Diameter*4;
}
double Volume() const
{
return m_Length*m_Height*m_Width;
}
void ShowVolume() const
{
cout<<Volume()<<endl;
}
};
//Main.cpp
#include<iostream>
#include"Cartorn.h"
int main()
{
CBottle bottle(1,2);
CCartorn car(bottle);
car.ShowVolume();
}
谁能告诉我怎么了?