SHARE
TWEET

Circle class (2)

Archon Dec 22nd, 2010 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. struct Circle{
  4.    float area;
  5.    float radius;
  6.  
  7.    Circle(float r): //c'tor
  8.    radius(r),
  9.    area(3.14 * r * r)
  10.    {}
  11. };
  12.  
  13. int main(){
  14.  
  15.    Circle c(3.16227766);
  16.    std::cout << c.area << " (should be 31.4)" << std::endl;
  17. }
RAW Paste Data
Want to get better at C++?
Learn to code C++ in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top