Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6889389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:09:00+00:00 2026-05-27T06:09:00+00:00

The more I research this problem, the more confused I seem to be getting.

  • 0

The more I research this problem, the more confused I seem to be getting. This is a homework problem which involves augmenting code given us by our professor. I know the problem has to do with the const keyword, and some very confusing new applications of it.

There is a generic class, Object, from which several subclasses (Sphere, Cone, Polygon) inherit. Here are the classes in Object:

public: // computational members                                                
    // return t for closest intersection with ray                               
    virtual float intersect(const Ray &ray) const = 0;

    // return color for intersection at t along ray r                           
    virtual const Vec3 appearance(const World &w,
                                  const Ray &r, float t) const = 0;

    //The following function is added by me
    virtual const Vec3 normal(Vec3 p);
};

I added the final function, normal.

So within, for instance, the Sphere class, this is implemented thusly:

const Vec3 Sphere::normal(Vec3 p)
{
  return (p - d_center).normalize();
}

When I `make’, I get the following error:

Appearance.cpp: In member function ‘const Vec3 Appearance::eval(const World&, const Vec3&, const Vec3&, Vec3, int) const’:
Appearance.cpp:46: error: passing ‘const Object’ as ‘this’ argument of ‘virtual const Vec3 Object::normal(Vec3)’ discards qualifiers
make: *** [Appearance.o] Error 1

Can you help me understand why this is happening? Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:09:01+00:00Added an answer on May 27, 2026 at 6:09 am

    When the error-message refers to the ‘this’ argument of a method, it means (a pointer to) the object that you’re calling the method on. For example, in shape->normal(v), shape is the this argument.

    To specify that a given method doesn’t modify its own object — its this argument — you need to append const to its declaration. So, change this:

    virtual const Vec3 normal(Vec3 p);
    

    to this:

    virtual const Vec3 normal(Vec3 p) const;
    

    to indicate that it’s “safe” to call normal(...) on a const object.

    Similarly, change this:

    const Vec3 Sphere::normal(Vec3 p)
    

    to this:

    const Vec3 Sphere::normal(Vec3 p) const
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question will seem obvious to those who haven't encountered the problem themselves. I
I've asked a similar question before, but I've done some more research and this
I believe (from some research reading) that counting down in for-loops is actually more
More than about LINQ to [insert your favorite provider here], this question is about
More detail to my question: HTML and JavaScript are called client-side code. C# and
More particularly - I have a window handle of another running application. This application
More specifically, I'm trying to check if given string (a sentence) is in Turkish.
EDIT After some more research I found that I cannot use a continuous form
This is more of a conceptual question. If it helps, lets say it falls
I came to work today and i found my hudson with this problem! I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.