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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:18:28+00:00 2026-06-17T03:18:28+00:00

When I try to compile my project I get a C2440 error saying ‘initializing’

  • 0

When I try to compile my project I get a C2440 error saying 'initializing' : cannot convert from 'vector<component_count>' to 'vector_2D'. The MSDN documentation on C2440 says The compiler cannot cast from 'type1' to 'type2'. I have a base class, vector:

template <unsigned int component_count>
class vector {...}

and a derived class, vector_2D:

class vector_2D : public vector<2>

My base class defines a default and copy constructor, and operator overloads. The code which gives me the error is:

vector_2D character_position = pen_position + vector_2D(offset_x, offset_y);

pen_position is created earlier as

vector_2D pen_position(string_position);

I can’t seem to fix my error. Can anyone point out what is going wrong and/or how to fix it?

  • 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-06-17T03:18:30+00:00Added an answer on June 17, 2026 at 3:18 am
    vector operator + (const vector& a_vector) const
    

    is the problem. You’re returning a base and then trying to assign it to the derived.

    The simplest fix is to provide an overload

    vector_2D operator + (const vector_2D& a_vector) const
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to compile this project I get the following error. I would
When I try to compile I get this error: 1>------ Build started: Project: snake,
When I try to compile project under framework 4, I get error: Filetracker: error
This is the error I get when I try and compile my project: Undefined
When I try to compile my VB.NET web project, I get an error that
When I try to compile Gforth 0.7.0, I get the following error: $ ./configure
I try to add Message.framework to my project frameworks directory. After that I compile
When I try compile with maven 3.0.4, Eclipse give me this error: Failed to
When I try to compile my program on ubuntu using gcc, i get these
When I try to compile a copy of my project on my local machine,

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.