Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » Program Problem

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
21.09.2004, 03:52 Uhr
~Silence
Gast


My program is simple, purpose is to give the volume of a cone... i keep coming out with the same error though that i don't know how to solve:

no match for 'ostream & = double'


This is my program:

C++:
// main.cpp
#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;


int main ()
{
  
  ifstream inFile;
  fstream outFile;
  int n;


const float  RADIUS = 20.0;
const float  HEIGHT = 25.0;
const float  VOLUME = n;
const double  PI = 3.1415;

float volume;

  cout << fixed << showpoint;


  cout << volume = 1/3.0 * PI * pow(RADIUS,2) * HEIGHT;


  cout << "The Volume of the Cone is: ";
  cout << "ft^2 = "<< n <<endl;
  
    
  return 0;
}




Bearbeitung von Pablo:

Use the CPP tags by yourself, please.


Dieser Post wurde am 21.09.2004 um 08:33 Uhr von Pablo editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
21.09.2004, 04:49 Uhr
Windalf
Der wo fast so viele Posts wie FloSoft...
(Operator)


till' yet I've thougt cone is something to eat
you've written a little bit complicated...


Zitat:

no match for 'ostream & = double'


this failure is here

C++:
cout << volume = 1/3.0 * PI * pow(RADIUS,2) * HEIGHT; //in this case you would have to use brackets
cout << volume = (1/3.0 * PI * pow(RADIUS,2) * HEIGHT); //in this case you would have to


there are still some other strange things in you code

try this perhaps

C++:
#include <iostream>
#include <cmath>

#ifndef M_PI    //in most cases pi is defined as M_PI in cmath ohterwise we define it
#define M_PI 3.1415926535897932384626433832795
#endif

//calculates the volume of a cone
double volume_cone(double radius, double height){return M_PI*radius*radius*height/3.;}

int main (){
    std::cout << "The Volume of the Cone is: "<<volume_cone(20.,25.)<<std::endl;
return 0;
}


--
...fleißig wie zwei Weißbrote

Dieser Post wurde am 21.09.2004 um 04:51 Uhr von Windalf editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
002
21.09.2004, 09:00 Uhr
(un)wissender
Niveauwart


cout << (volume = 1/3.0) * PI * pow(RADIUS,2) * HEIGHT; would be ok too, but still quit clumsy.
--
Wer früher stirbt ist länger tot.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: