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 7078507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:33:23+00:00 2026-05-28T06:33:23+00:00

I defined a class like this: Quaternion& conjugate(); //negates the vector component of the

  • 0

I defined a class like this:

Quaternion& conjugate();        //negates the vector component of the quaternion
Quaternion  conjugate() const;  //same but in without modifying the class...

Quaternion& operator =  (Quaternion const& Qrhs);
Quaternion& operator *= (Quaternion const& Q);
Quaternion  operator  *  (Quaternion const& Qrhs) const;

now I use this functions like this:

PRINTVAR(*this);                //this is the first time printed (a little macro to print line and file)
Quaternion vQ(0.,vn), resQ;
resQ = vQ*(this->conjugate());  //this is the method I want to discuss...
PRINTVAR(*this);                //this is the second time
resQ = *this * resQ;

and this is the output

*this: (0:0:0:0) at line: 128 in file: Quaternions.cpp
*this: (-0:-0:-0:0) at line: 131 in file: Quaternions.cpp

I thought that by calling the operator * in the line resQ = vQ*(this should be called as const)...
why if I print *this again is changed?

here is the definition of the conjugate function:

Quaternion& Quaternion::conjugate(){
/* Given:  Nothing
 * Task:   Invert sign of the vector
 * Return: the class which will be modified
*/
    V3 vec;
    vec = -(this->getVector());
    x() = vec[0];
    y() = vec[1];
    z() = vec[2];
    return *this;
}

Quaternion Quaternion::conjugate() const{
    Quaternion result(*this);
    result.conjugate();
    return result;
}
  • 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-28T06:33:23+00:00Added an answer on May 28, 2026 at 6:33 am

    If the code you showed is in a non-const method, than the this pointer is non-const, and the non-const conjugate method is of course a better match than the const one. Return types aren’t considered in overload decisions. If you want to insist that the const version is used, you can add constness: resQ = vQ*(static_cast<const Quaternion*>(this)->conjugate());

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class defined like this, with the appropriate getter and setter methods...
I have a Customer class defined like this: @Entity public class Customer { //...
We have a class Car defined like this in a car.rb file class Car
I have a declarative table defined like this: class Transaction(Base): __tablename__ = transactions id
I defined a simple Document, like this: class Company(Document): screen_name = StringField(max_length=100, required=True, unique=True)
I have a ViewModel defined like this: public class LocationTreeViewModel<TTree> : ObservableCollection<TTree>, INotifyPropertyChanged TTree
Let's say that I've defined a dependency like this: public class MySampleClass {public static
I have a class called MainGame, which is defined like this in my .h:
I have this problem.... in my viewcontroller.h I defined my class like this: myClass*
I have a class defined like this: public class StateMachineMetadata<T> where T: struct {

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.