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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:16:39+00:00 2026-05-27T22:16:39+00:00

Is it possible to initializate a class like this? Quaternion::Quaternion(){ //default without arguments Quaternion(0.,V3(0.,0.,0.));

  • 0

Is it possible to initializate a class like this?

Quaternion::Quaternion(){ //default without arguments
    Quaternion(0.,V3(0.,0.,0.));
}


Quaternion::Quaternion(double s, V3 v){ //with scalar and vector as a argument
    coords[0] = s;
    coords[1] = v[0];
    coords[2] = v[1];
    coords[3] = v[2];
}

because this is the output:

QUATERNION TEST
(2.122e-313:-3.22469e-232:2.122e-313:-1.998) //instanciated with Quaternion q;
(4:1:2:3) // instanciated with the Quaternion q(4,1,2,3);
(4:-1:-2:-3) // conjugated of the one above

and first one is not initializated as 0. as it should be… why?

  • 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-27T22:16:40+00:00Added an answer on May 27, 2026 at 10:16 pm

    Not in C++03, but the recent version of C++ allows delegating constructors:

    Quaternion() : Quaternion(0.0, V3(0.0,0.0,0.0)) { }
    

    In a delegating constructor, the initializer list must have precisely one element, which is another constructor (and obviously there mustn’t be any circular references).

    Pre-C++11 you don’t really get around copy/pasting if you want to actually initialize your class members directly in the constructor. Maybe you would like to use default arguments, though? Some people object to those….

    explicit Quaternion(double s = 0.0, V3 v = V3(0.0,0.0,0.0)) { /* ... */ }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider a class like this one: class MyReferenceClass { public: MyReferenceClass(); const double ImportantConstant1;
Is it somehow possible to test warnings i Ruby using RSpec? Like this: class
I have a static SessionFactory class that initializes an NHibernate session factory. Because this
My classes look something like this (I include only the relevant properties): public class
I have a class that looks roughly like this: template<std::size_t dim> class Foo {
I have a Java class that looks like this: public class My_ABC { int
I have created a delegated Array class like this: class LeadPartArray < DelegateClass(Array) def
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
I have this class: public class MyEntity { public virtual int Id { get;
I want to be able to initialize a class just like I initialize a

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.