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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:19:16+00:00 2026-06-12T14:19:16+00:00

I have this mesh class which is spread out over two files (mesh.h and

  • 0

I have this mesh class which is spread out over two files (mesh.h and mesh.cpp). now it worked perfectly until i added a position variable to it (of type Vector2d). when i added the variable it still ran as normal but as soon as i used it in one of the functions it gave me an error saying a bunch of my variables are not declared. let me show you exactly what i did:

class Mesh{
  public:
  Mesh() {
     Rectangle;
     position = Vector2d(0,0);
  }

  Mesh(Vector2dVector Vertices) {
    Set(Vertices);
    position = Vector2d(0,0);
  };

  Vector2dVector GetVetices() { return vertices; };
  Vector2d SetPosition(Vector2d p) { position = p; }
  float GetVertexCount() { return vertexCount; };
  float GetTriangleCount() { return triangleCount; }

  void  Set(Vector2dVector Vertices){
    Triangulate::Process(Vertices,vertices);
    vertexCount = vertices.size();
    triangleCount = vertexCount/3;
  };

  void Render();
  static Mesh Circle();
  static Mesh Rectangle();
  static Mesh Triangle();

  private:
  Vector2dVector vertices;
  Vector2d position;
  int triangleCount;
  int vertexCount;
};

this ran ok but when i added this to the function render at file mesh.cpp it gave me an error

#include "mesh.h"

void Mesh::Render() {
 glBegin (GL_TRIANGLES); 
     for (int i=0; i<GetTriangleCount(); i++) {
         const Vector2d &p1 = vertices[i*3+0];
         const Vector2d &p2 = vertices[i*3+1];
         const Vector2d &p3 = vertices[i*3+2];
         glVertex2f(position.GetX() + p1.GetX(),position.GetY() + p1.GetY());
         glVertex2f(position.GetX() + p2.GetX(),position.GetY() + p2.GetY());
         glVertex2f(position.GetX() + p3.GetX(),position.GetY() + p3.GetY());
     }
 glEnd ();
}

here’s the error message

In file included from main.cpp:3:
mesh.h: In constructor `Mesh::Mesh()':
mesh.h:5: error: no matching function for call to `Vector2d::Vector2d()'
triangulation.h:43: note: candidates are: Vector2d::Vector2d(const Vector2d&)
triangulation.h:46: note:                 Vector2d::Vector2d(float, float)
mesh.h: In constructor `Mesh::Mesh(Vector2dVector)':
mesh.h:10: error: no matching function for call to `Vector2d::Vector2d()'

so after i deleted all of the position.Get.. method calls from the function it still gave me the same error eventhough it didn’t before i added and deleted. i have been working with computers for about 4 years now and i’ve never ever seen i computer act like this. if someone could please explain to me what i’m doing wrong that would be very helpful. btw i’m using DevC++ version 4.9.9.2 so i think it mite have something to do with this.

thanks for reading and sorry it’s soooooo long.

  • 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-12T14:19:17+00:00Added an answer on June 12, 2026 at 2:19 pm

    You have to initialize the vector in the constructor’s initializer list, not in the constructor body:

    Mesh(): position(0,0) {
       Rectangle;
    }
    
    Mesh(Vector2dVector Vertices) : position(0,0) {
      Set(Vertices);
    };
    

    Otherwise position is going to be default constructed, which would fail since you didn’t define a default constructor.

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

Sidebar

Related Questions

I have a class which looks approximately like this: class MeshClass { public: Anchor
i have created this class for mesh loading it works but i added this
I have this object I'm loading with THREE.objLoader and then create a mesh with
I have this form, in which i need to populate a combo box with
I have this form: <%= form_tag posts_path, :method => :get, :class => search_nav do
I want to implement a Mesh class for a CG project, but have run
I have been working very hard on figuring this out and just can't understand
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
Have this self-made slider: http://jsfiddle.net/wyc3P/4/ What it does: takes min and max values in
I have this string 2012-06-27 16:17:06 and I want to convert it to GMT

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.