CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: calculate dimensions of a circle in c++

1. Junior Member
Join Date
Jul 2011
Posts
5

## calculate dimensions of a circle in c++

Code:
```#ifndef CIRCLE_H
#define CIRCLE_H

class Circle {
public:
//constructors
Circle();
Circle(double r);
//setter
//getter
//calculate the diameter of a circle
double computeDiameter()const;
//calculate the area of a circle
double computeArea()const;
//calculate the Circumference of a circle
double computeCircumference()const;
//checks if radius of circle is bigger
**bool isBigger(const Circle& other) const;**

private:
//private data members
};

#endif // CIRCLE_H

#include "circle.h"
#include "math.h"
#include <iostream>
#include <QString>
#include <sstream>
using namespace std;

Circle::Circle()
{
}

Circle::Circle(double r)
{
}

}

}

double Circle::computeDiameter()const{
}

double Circle::computeArea()const {
}

double Circle::computeCircumference()const {
}

#include <iostream>
#include <QTextStream>
#include "circle.h"
using namespace std;

int main(){
QTextStream cout(stdout);

Circle c1,c2;     // input

cout << "Circle with radius " << c1.getRadius() << " has: " << endl;
cout<< "Diameter " << c1.computeDiameter() << " cm " <<endl;
cout<< "Area " << c1.computeArea() << " cm" <<endl;
cout<< "Circumference " << c1.computeCircumference()<< " cm " <<endl<<endl;

cout << "Circle with radius " << c2.getRadius() << " has: " << endl;
cout<< "Diameter " << c2.computeDiameter() << " cm " <<endl;
cout<< "Area " << c2.computeArea() << " cm" <<endl;
cout<< "Circumference " << c2.computeCircumference()<< " cm " <<endl<<endl;

return 0;
}```
The function isBigger() returns true (or false) if the radius of the Circle instance on which the function is invoked is bigger (or smaller) than the radius of the Circle instance passed to the function.: Can someone help me to implement this function?
Last edited by annitaz; July 4th, 2013 at 03:48 AM.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•