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

  • Home
  • SEARCH
  • 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 3438884
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:14:30+00:00 2026-05-18T08:14:30+00:00

I’m trying to get my prof’s overengineered C++ code to compile. This is the

  • 0

I’m trying to get my prof’s overengineered C++ code to compile. This is the code I have:

/**
 * Vector class.
 * Common mathematical operations on vectors in R3.
 *
 * Written by Robert Osada, March 1999.
 **/
#ifndef __VECTOR_H__
#define __VECTOR_H__

/**
 * Vector3
 **/
struct Vector3f
{
  // coordinates
  float x, y, z;

  // norm
  float      normSquared () { return x*x+y*y+z*z; }
  double norm        () { return sqrt(normSquared()); }

  // boolean operators
  bool operator == (const Vector3f& v) const { return x==v.x && y==v.y && z==v.z; }
  bool operator != (const Vector3f& v) const { return x!=v.x || y!=v.y || z!=v.z; }

  // operators
  Vector3f  operator +  (const Vector3f &v) const { return Vector3f(x+v.x, y+v.y, z+v.z); }
  Vector3f& operator += (const Vector3f &v)       { x+=v.x; y+=v.y; z+=v.z; return *this; }
  Vector3f  operator -  () const                 { return Vector3f(-x, -y, -z); }
  Vector3f  operator -  (const Vector3f &v) const { return Vector3f(x-v.x, y-v.y, z-v.z); }
  Vector3f& operator -= (const Vector3f &v)       { x-=v.x; y-=v.y; z-=v.z; return *this; }
  Vector3f  operator *  (float s) const              { return Vector3f(x*s, y*s, z*s); }
  Vector3f& operator *= (float s)                { x*=s; y*=s; z*=s; return *this; }
  Vector3f  operator /  (float s) const          { assert(s); return (*this)* (1/s); }
  Vector3f& operator /= (float s)                { assert(s); return (*this)*=(1/s); }

 // create a vector
 Vector3f (float x_=0, float y_=0, float z_=0) : x(x_), y(y_), z(z_) {};

 // set coordinates
 void set (float x_, float y_, float z_) { x=x_; y=y_; z=z_; }
};

inline float Dot (const Vector3f& l, const Vector3f r)
{
  return l.x*r.x + l.y*r.y + l.z*r.z;
}

// cross product
inline Vector3f Cross (const Vector3f& l, const Vector3f& r)
{
  return Vector3f(
    l.y*r.z - l.z*r.y,
    l.z*r.x - l.x*r.z,
    l.x*r.y - l.y*r.x );
}

#include "Misc.h"
/*
inline Vector3f Min (const Vector3f &l, const Vector3f &r)
{
  return Vector3f(Min(l.x,r.x), Min(l.y,r.y), Min(l.z,r.z));
}

inline Vector3f Max (const Vector3f &l, const Vector3f &r)
{
  return Vector3f(Max(l.x,r.x), Max(l.y,r.y), Max(l.z,r.z));
}
*/
#endif

and I’m getting the error on the line which defines normSquared(). It seems to give an error regardless of which method comes first in the struct. Does any have any suggestions?

  • 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-18T08:14:31+00:00Added an answer on May 18, 2026 at 8:14 am

    Are you trying to compile with a C compiler maybe? If you try to compile your C++ code with a C only compiler I think you would get those type of messages.

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

Sidebar

Related Questions

No related questions found

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.