bug....help!

#include <iostream>
#include <cstdlib>

using namespace std;

template <class burner>
class device
{
private:

int n;
burner *P,*FR,*kind_burner;
public:
device();
burner b_short();
burner get_burner();
burner get_max_power();
burner get_fuel_max_power();

};
template <class burner>
device<burner>::device()
{
int i;

cout<<"Enter :\n The number of burners for that specific type :\n";
cin>>n;

P=(burner*)malloc(n*sizeof(burner));
if (P==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(1);
}
for (i=0;i<n;i++) {
cout<<"The maximum power of the burner:\n";
cin>>P[i];
}
FR=(burner*)malloc(n*sizeof(burner));
if (FR==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(2);
}
for (i=0;i<n;i++) {
cout<<"The fuels required for the maximum power of the burner :\n";
cin>>FR[i];
}
kind_burner=(burner*)malloc(n*sizeof(burner));
if (kind_burner==NULL) {
cout<<"there is no memory to be allocated!\n";
exit(3);
}
for (i=0;i<n;i++) {
kind_burner[i]=P[i]/FR[i];
}

}

class oil_burner
{
protected:
int n,*id_burner;
float *P,*FR,*cost_fuel_per_unit,*cost_burner,*cost_maintenance;

public:
oil_burner();
float b_short();
};
oil_burner::oil_burner()
{
int i;
cout<<"Enter :\n The number of burners for that specific type :\n";
cin>>n;
id_burner=(int*)malloc(n*sizeof(int));
if (id_burner==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(1);
}
for (i=0;i<n;i++) {
cout<<"The identity of the burner :\n";
cin>>id_burner[i];
}
P=(float*)malloc(n*sizeof(float));
if (P==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(2);
}
for (i=0;i<n;i++) {
cout<<"The maximum power of the burner:\n";
cin>>P[i];
}
FR=(float*)malloc(n*sizeof(float));
if (FR==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(3);
}
for (i=0;i<n;i++) {
cout<<"The fuels required for the maximum power of the burner :\n";
cin>>FR[i];
}
cost_fuel_per_unit=(float*)malloc(n*sizeof(float));
if (cost_fuel_per_unit==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(4);
}
for (i=0;i<n;i++) {
cout<<"The cost of fuels per unit :\n";
cin>>cost_fuel_per_unit[i];
}
cost_burner=(float*)malloc(n*sizeof(float));
if (cost_burner==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(5);
}
for (i=0;i<n;i++) {
cout<<"The cost of the burner :\n";
cin>>cost_burner[i];
}
cost_maintenance=(float*)malloc(n*sizeof(float));
if (cost_maintenance==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(6);
}
for (i=0;i<n;i++) {
cout<<"The maintenace cost of the installation :\n";
cin>>cost_maintenance[i];
}


}



template <>
class device<oil_burner>

{
private:

int n;
oil_burner *P,*FR,*kind_burner;
public:
device();

};

device<oil_burner>::device()
{
int i;

cout<<"Enter :\n The number of burners for that specific type :\n";
cin>>n;

P=(oil_burner*)malloc(n*sizeof(oil_burner));
if (P==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(1);
}
for (i=0;i<n;i++) {
cout<<"The maximum power of the burner:\n";
cin>>P[i];
}

}
int main ()
{
int days_operation;
float min_power_burner,cost_burner,cost_maintenance;
cout<<"Enter :\n The minmum power burner of the installation :\n";
cin>>min_power_burner;
cout<<"The available money for purchase burner :\n";
cin>>cost_burner;
cout<<"The money required for the maintenance of the burner :\n";
cin>>cost_maintenance;
cout<<"The days operates the heating during the year :\n";
cin>>days_operation;
device<oil_burner> obj1;




return 0;
}
bug...line 236

C:\Users\rafail medentizidis\Desktop\F7349\main.cpp||In constructor 'device<oil_burner>::device()':|
C:\Users\rafail medentizidis\Desktop\F7349\main.cpp|236|error: no match for 'operator>>' in 'std::cin >> *(((device<oil_burner>*)this)->device<oil_burner>::P + ((unsigned int)(((unsigned int)i) * 28u)))'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\istream|119|note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\istream|123|note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\istream|130|note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\istream|166|note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char, _Traits = std::char_traits<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\istream|170|note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char, _Traits = std::char_traits<char>]|


Bit hard to tell what line 236 is without code tags.
cin>>P[i];

The compiler has no idea what >> means in the context of input to a oil_burner object.
Last edited on
Topic archived. No new replies allowed.