function to calculate the Circumference of a circle

This is a discussion on function to calculate the Circumference of a circle within the C++ Programming forums, part of the General Programming Boards category; here's my function double Circle::calcPerimeter() const { return perimeter = 2 * radius * 3.1425; } on visual c++ i ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    20

    function to calculate the Circumference of a circle

    here's my function

    double Circle::calcPerimeter() const
    {
    return perimeter = 2 * radius * 3.1425;
    }

    on visual c++ i get this error....

    error C2166: l-value specifies const object

    any ideas......?

  2. #2
    Registered User JasonLikesJava's Avatar
    Join Date
    Mar 2002
    Posts
    175

    Talking

    Maybe this'll work

    double Circle::calcPerimeter()
    {
    return 2 * radius * 3.1425;
    }

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    20
    its for an assignment..which the requires the function to be a const....using the variable name perimeter.

  4. #4
    Registered User JasonLikesJava's Avatar
    Join Date
    Mar 2002
    Posts
    175
    what about:

    const double Circle::calcPerimeter()
    {
    return perimeter = 2 * radius * 3.1425;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Brand new to C need favor
    By dontknowc in forum C Programming
    Replies: 5
    Last Post: 09-21-2007, 10:08 AM
  2. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 09:18 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21