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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:21:25+00:00 2026-05-26T19:21:25+00:00

I have Vector class, representing a 3D point, written as follows in Vector.h :

  • 0

I have Vector class, representing a 3D point, written as follows in Vector.h:

class Vector {
  public:
    float x,y,z;
    Vector(float _x=0.0,float _y=0.0,float _z=0.0){x=_x;y=_y;z=_z;};
    operator float *() { return &x;};
};

I also declare a extern vector<Vector>model_vertices; on model.h

On a model.cpp file I implement Vector.h and declare a std::vector<Vector>model_vertices; globally (yes, I know the vector/Vector thing is confusing, but I must use the Vector naming for consistency).

On model.cpp, when initializing the contents of this vector I use a for loop with the following content:

float X,Y,Z;

offFileStream>>X;
offFileStream>>Y;
offFileStream>>Z;


Vector v=new Vector(X,Y,Z);


model_vertices[loadVertexIndex]=v;

I get the following error:

error C2440: 'initializing' : cannot convert from 'Vector *' to 'Vector'

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-26T19:21:26+00:00Added an answer on May 26, 2026 at 7:21 pm

    The error is on this line:

    Vector v=new Vector(X,Y,Z);
    

    v is of type Vector, but new Vector(X,Y,Z) returns a Vector*:

    What you probably wanted instead is just:

    Vector v(X,Y,Z);
    

    As a side note, I didn’t see you initialize a size for the model_vertices. So you may want to use push_back() instead.

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

Sidebar

Related Questions

Suppose I have a class: public class Vector { public float X { get;
I have a vector class with a properly overloaded Vect*float operator and am trying
I have class A: public B { ...} vector<A*> v; I want to do
I have a class class ChartLine{ protected: vector<Point> line; // points connecting the line
I have two classes, point and pixel: class point { public: point(int x, int
I have a vector class with hashCode() implemented. It wasn't written by me, but
I have a base class, Parameter, and two derived classes: Scalar & Vector. In
I have a math vector class that is designed as follows: class Vector3D {
I am practicing with functions on the vector class. i have written a function
I have a vector-like class that contains an array of objects of type T

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.